reconstruct after editing

This commit is contained in:
Rocky Duan
2012-08-24 02:17:58 -07:00
parent cc5fbdd5a7
commit fe74f9bc85
2 changed files with 15 additions and 3 deletions

View File

@@ -222,7 +222,7 @@ def extend_content(content):
def safe_content(content):
fields = [
'id', 'body', 'course_id', 'anonymous', 'endorsed',
'id', 'title', 'body', 'course_id', 'anonymous', 'endorsed',
'parent_id', 'thread_id', 'votes', 'closed',
'created_at', 'updated_at', 'depth', 'type',
'commentable_id', 'comments_count', 'at_position_list',

View File

@@ -316,8 +316,12 @@ if Backbone?
success: (response, textStatus) =>
DiscussionUtil.clearFormErrors @$(".discussion-update-errors")
@$discussionContent().replaceWith(response.html)
@model.set response.content
@model.updateInfo response.annotated_content_info
if @model.get('type') == 'thread'
@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) ->
@$(".discussion-content-edit").hide()
@@ -388,6 +392,14 @@ if Backbone?
@initTitle()
@initBody()
@initCommentViews()
reconstruct: ->
@initBindings()
@initLocal()
@initTimeago()
@initTitle()
@initBody()
@delegateEvents()
class @Thread extends @Content
urlMappers: