improving new post
This commit is contained in:
@@ -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("")
|
||||
#@$el.children(".threads").prepend($thread)
|
||||
#@$el.children(".blank").remove()
|
||||
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">
|
||||
|
||||
Reference in New Issue
Block a user