Commit d82534bc by Arjun Singh

improving new post

parent 95cfbcc8
......@@ -10,7 +10,8 @@ class @DiscussionRouter extends Backbone.Router
@nav.on "threads:rendered", @setActiveThread
@nav.render()
@newPostView = new NewPostView(el: $(".new-post-article"))
@newPostView = new NewPostView(el: $(".new-post-article"), collection: @discussion)
@newPostView.on "thread:created", @navigateToThread
allThreads: ->
# TODO: Do something reasonable here
......
......@@ -109,6 +109,7 @@ class @NewPostView extends Backbone.View
createPost: (event) ->
event.preventDefault()
title = @$(".new-post-title").val()
body = @$(".new-post-body").val()
tags = @$(".new-post-tags").val()
......@@ -136,16 +137,21 @@ class @NewPostView extends Backbone.View
auto_subscribe: follow
error: DiscussionUtil.formErrorHandler(@$(".new-post-form-errors"))
success: (response, textStatus) =>
console.log "SUCCESS"
#DiscussionUtil.clearFormErrors(@$(".new-post-form-errors"))
#$thread = $(response.html)
#@$(".new-post-title").val("").attr("prev-text", "")
#@$(".new-post-body").val("").attr("prev-text", "")
#@$(".new-post-tags").val("")
#@$(".new-post-tags").importTags("")
console.log response
thread = new Thread response['content']
DiscussionUtil.clearFormErrors(@$(".new-post-form-errors"))
@$el.hide()
@$(".new-post-title").val("").attr("prev-text", "")
@$(".new-post-body").val("").attr("prev-text", "")
@$(".new-post-tags").val("")
@$(".new-post-tags").importTags("")
@collection.add thread
@collection.trigger "reset"
@trigger "thread:created", thread.id
#@$el.children(".threads").prepend($thread)
# no idea what this is
#@$el.children(".blank").remove()
#@$(".new-post-similar-posts").empty()
#@$(".new-post-similar-posts-wrapper").hide()
#DiscussionUtil.setWmdContent @$el, $.proxy(@$, @), "new-post-body", ""
......
......@@ -40,9 +40,9 @@
</div>
</div>
<div class="options">
<input type="checkbox" name="follow" class="discussion-anonymous" class="discussion-follow" id="new-post-follow" checked><label for="new-post-follow">follow this post</label>
<input type="checkbox" name="follow" class="discussion-follow" class="discussion-follow" id="new-post-follow" checked><label for="new-post-follow">follow this post</label>
<br>
<input type="checkbox" name="follow" class="discussion-follow" id="new-post-anonymous" checked><label for="new-post-anonymous">post anonymously</label>
<input type="checkbox" name="anonymous" class="discussion-anonymous" id="new-post-anonymous" checked><label for="new-post-anonymous">post anonymously</label>
</div>
</div>
<div class="right-column">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment