From b9f7bb70d0cd5548eea74bf110b18a90230c2e96 Mon Sep 17 00:00:00 2001 From: Arvind Date: Wed, 5 Mar 2014 21:32:34 +0530 Subject: [PATCH] Code refactor. Fixing issues with saving a reply. --- app.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 4bce8ee..37cacf8 100644 --- a/app.js +++ b/app.js @@ -18,6 +18,9 @@ }; }, initialize: function() { + }, + isValid: function() { + return true; } }); var Comment = Backbone.Model.extend({ @@ -108,7 +111,7 @@ render: function() { if(this.model.get('how').get('comment').length) { if(this.model.get('how').get('replyTo').length) { - var item = '#' + this.model.get('how')['replyTo']; + var item = '#' + this.model.get('how').get('replyTo'); var el = $(item).parent(); $(el).append(this.template(this.model.toJSON())); } @@ -182,9 +185,9 @@ }, showOne: function(model) { - if(model.get('how').isNew === undefined) { - console.log(model); + if(model.get('how').isValid === undefined) { model.set({'how': new How(model.get('how'))}); + console.log(model); } var view = new CommentView({model:model}); $(this.el).append(view.render().el); -- 1.7.10.4