From 1be378e6970ef9edfa56f5bb67244ebf03069bb8 Mon Sep 17 00:00:00 2001 From: Ibrahim Awwal Date: Tue, 11 Sep 2012 14:31:03 -0700 Subject: [PATCH] Render comment replies properly, and update them after receiving a response. --- .../src/discussion/views/thread_response_view.coffee | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lms/static/coffee/src/discussion/views/thread_response_view.coffee b/lms/static/coffee/src/discussion/views/thread_response_view.coffee index b675d9edd9..f4719800cc 100644 --- a/lms/static/coffee/src/discussion/views/thread_response_view.coffee +++ b/lms/static/coffee/src/discussion/views/thread_response_view.coffee @@ -44,6 +44,7 @@ if Backbone? view = new ResponseCommentView(model: comment) view.render() @$el.find(".comments li:last").before(view.el) + view toggleVote: (event) -> event.preventDefault() @@ -81,8 +82,8 @@ if Backbone? body = @$(".comment-form-input").val() if not body.trim().length return - comment = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username"), user_id: window.user.get("id")) - @renderComment(comment) + comment = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username"), user_id: window.user.get("id"), id:"unsaved") + view = @renderComment(comment) @trigger "comment:add", comment @$(".comment-form-input").val("") @@ -93,7 +94,9 @@ if Backbone? dataType: 'json' data: body: body - + success: (response, textStatus) -> + comment.set(response.content) + view.render() # This is just to update the id for the most part, but might be useful in general delete: (event) -> event.preventDefault() if not @model.can('can_delete')