From aa86003cf9e3dfa80d0fe1f0b1c5379344279b96 Mon Sep 17 00:00:00 2001 From: Dennis Schubert Date: Thu, 9 Jul 2015 03:24:15 +0200 Subject: [PATCH] Keep the hacky scope workaround in comments.js because we still are supporting browsers without .bind() and I do not want to break the patterns here. Follow up to #6171 - I wanted to avoid feedback loop delays for that little change. --- app/assets/javascripts/app/collections/comments.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/app/collections/comments.js b/app/assets/javascripts/app/collections/comments.js index 2a80a28cd..9ecf4f047 100644 --- a/app/assets/javascripts/app/collections/comments.js +++ b/app/assets/javascripts/app/collections/comments.js @@ -11,13 +11,14 @@ app.collections.Comments = Backbone.Collection.extend({ }, make : function(text) { + var self = this; var comment = new app.models.Comment({ "text": text }); var deferred = comment.save({}, { url: "/posts/"+ this.post.id +"/comments", success: function() { - comment.set({author: app.currentUser.toJSON(), parent: this.post }); - this.add(comment); + comment.set({author: app.currentUser.toJSON(), parent: self.post }); + self.add(comment); } });