Skip to content

Commit

Permalink
Rendering comment new view for new posts. Not assigning newly created…
Browse files Browse the repository at this point in the history
… models to view model to avoid updates instead of creates
  • Loading branch information
rohitnair committed Mar 28, 2012
1 parent 7dc34bf commit b899712
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class RailsBackboneRelational.Views.Comments.NewView extends Backbone.View

@collection.create(@model.toJSON(),
success: (comment) =>
@model = comment
view = new RailsBackboneRelational.Views.Comments.CommentView({model : @model})
#@model = comment
view = new RailsBackboneRelational.Views.Comments.CommentView({model : comment})
$(@.el).parent().prev().find('.comments-list').append(view.render().el)
@$('.content').val('')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ class RailsBackboneRelational.Views.Posts.NewView extends Backbone.View

@collection.create(@model.toJSON(),
success: (post) =>
@model = post
view = new RailsBackboneRelational.Views.Posts.PostView({model : @model})
view = new RailsBackboneRelational.Views.Posts.PostView({model : post})
$("#posts-list").prepend(view.render().el)
comments_view = new RailsBackboneRelational.Views.Comments.IndexView(comments: post.get('comments'))
view.$(".comments").html(comments_view.render().el)
new_comment_view = new RailsBackboneRelational.Views.Comments.NewView(collection: post.get('comments'))
view.$(".new_comment").html(new_comment_view.render().el)
$("#title").val('')

error: (post, jqXHR) =>
Expand Down

0 comments on commit b899712

Please sign in to comment.