Commit d82534bc by Arjun Singh

improving new post

parent 95cfbcc8
...@@ -10,7 +10,8 @@ class @DiscussionRouter extends Backbone.Router ...@@ -10,7 +10,8 @@ class @DiscussionRouter extends Backbone.Router
@nav.on "threads:rendered", @setActiveThread @nav.on "threads:rendered", @setActiveThread
@nav.render() @nav.render()
@newPostView = new NewPostView(el: $(".new-post-article")) @newPostView = new NewPostView(el: $(".new-post-article"), collection: @discussion)
@newPostView.on "thread:created", @navigateToThread
allThreads: -> allThreads: ->
# TODO: Do something reasonable here # TODO: Do something reasonable here
......
...@@ -109,6 +109,7 @@ class @NewPostView extends Backbone.View ...@@ -109,6 +109,7 @@ class @NewPostView extends Backbone.View
createPost: (event) -> createPost: (event) ->
event.preventDefault()
title = @$(".new-post-title").val() title = @$(".new-post-title").val()
body = @$(".new-post-body").val() body = @$(".new-post-body").val()
tags = @$(".new-post-tags").val() tags = @$(".new-post-tags").val()
...@@ -136,16 +137,21 @@ class @NewPostView extends Backbone.View ...@@ -136,16 +137,21 @@ class @NewPostView extends Backbone.View
auto_subscribe: follow auto_subscribe: follow
error: DiscussionUtil.formErrorHandler(@$(".new-post-form-errors")) error: DiscussionUtil.formErrorHandler(@$(".new-post-form-errors"))
success: (response, textStatus) => success: (response, textStatus) =>
console.log "SUCCESS" console.log response
#DiscussionUtil.clearFormErrors(@$(".new-post-form-errors")) thread = new Thread response['content']
#$thread = $(response.html) DiscussionUtil.clearFormErrors(@$(".new-post-form-errors"))
#@$(".new-post-title").val("").attr("prev-text", "") @$el.hide()
#@$(".new-post-body").val("").attr("prev-text", "") @$(".new-post-title").val("").attr("prev-text", "")
#@$(".new-post-tags").val("") @$(".new-post-body").val("").attr("prev-text", "")
#@$(".new-post-tags").importTags("") @$(".new-post-tags").val("")
@$(".new-post-tags").importTags("")
@collection.add thread
@collection.trigger "reset"
@trigger "thread:created", thread.id
#@$el.children(".threads").prepend($thread) #@$el.children(".threads").prepend($thread)
# no idea what this is
#@$el.children(".blank").remove() #@$el.children(".blank").remove()
#@$(".new-post-similar-posts").empty() #@$(".new-post-similar-posts").empty()
#@$(".new-post-similar-posts-wrapper").hide() #@$(".new-post-similar-posts-wrapper").hide()
#DiscussionUtil.setWmdContent @$el, $.proxy(@$, @), "new-post-body", "" #DiscussionUtil.setWmdContent @$el, $.proxy(@$, @), "new-post-body", ""
......
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
</div> </div>
</div> </div>
<div class="options"> <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> <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> </div>
<div class="right-column"> <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