Commit fe74f9bc by Rocky Duan

reconstruct after editing

parent cc5fbdd5
...@@ -222,7 +222,7 @@ def extend_content(content): ...@@ -222,7 +222,7 @@ def extend_content(content):
def safe_content(content): def safe_content(content):
fields = [ fields = [
'id', 'body', 'course_id', 'anonymous', 'endorsed', 'id', 'title', 'body', 'course_id', 'anonymous', 'endorsed',
'parent_id', 'thread_id', 'votes', 'closed', 'parent_id', 'thread_id', 'votes', 'closed',
'created_at', 'updated_at', 'depth', 'type', 'created_at', 'updated_at', 'depth', 'type',
'commentable_id', 'comments_count', 'at_position_list', 'commentable_id', 'comments_count', 'at_position_list',
......
...@@ -316,8 +316,12 @@ if Backbone? ...@@ -316,8 +316,12 @@ if Backbone?
success: (response, textStatus) => success: (response, textStatus) =>
DiscussionUtil.clearFormErrors @$(".discussion-update-errors") DiscussionUtil.clearFormErrors @$(".discussion-update-errors")
@$discussionContent().replaceWith(response.html) @$discussionContent().replaceWith(response.html)
@model.set response.content if @model.get('type') == 'thread'
@model.updateInfo response.annotated_content_info @model = new Thread response.content
else
@model = new Comment $.extend {}, response.content, { thread: @model.get('thread') }
@reconstruct()
@model.updateInfo response.annotated_content_info, { forceUpdate: true }
cancelEdit: (event) -> cancelEdit: (event) ->
@$(".discussion-content-edit").hide() @$(".discussion-content-edit").hide()
...@@ -389,6 +393,14 @@ if Backbone? ...@@ -389,6 +393,14 @@ if Backbone?
@initBody() @initBody()
@initCommentViews() @initCommentViews()
reconstruct: ->
@initBindings()
@initLocal()
@initTimeago()
@initTitle()
@initBody()
@delegateEvents()
class @Thread extends @Content class @Thread extends @Content
urlMappers: urlMappers:
'retrieve' : -> DiscussionUtil.urlFor('retrieve_single_thread', @discussion.id, @id) 'retrieve' : -> DiscussionUtil.urlFor('retrieve_single_thread', @discussion.id, @id)
......
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