Commit b9f7bb70d0cd5548eea74bf110b18a90230c2e96
Code refactor. Fixing issues with saving a reply.
| | | | 18 | }; | 18 | }; |
---|
19 | }, | 19 | }, |
---|
20 | initialize: function() { | 20 | initialize: function() { |
---|
| | 21 | }, |
---|
| | 22 | isValid: function() { |
---|
| | 23 | return true; |
---|
21 | } | 24 | } |
---|
22 | }); | 25 | }); |
---|
23 | var Comment = Backbone.Model.extend({ | 26 | var Comment = Backbone.Model.extend({ |
---|
… | | … | |
---|
111 | render: function() { | 111 | render: function() { |
---|
112 | if(this.model.get('how').get('comment').length) { | 112 | if(this.model.get('how').get('comment').length) { |
---|
113 | if(this.model.get('how').get('replyTo').length) { | 113 | if(this.model.get('how').get('replyTo').length) { |
---|
114 | var item = '#' + this.model.get('how')['replyTo']; | | var item = '#' + this.model.get('how')['replyTo']; |
---|
| | 114 | var item = '#' + this.model.get('how').get('replyTo'); | 115 | var el = $(item).parent(); | 115 | var el = $(item).parent(); |
---|
116 | $(el).append(this.template(this.model.toJSON())); | 116 | $(el).append(this.template(this.model.toJSON())); |
---|
117 | } | 117 | } |
---|
… | | … | |
---|
185 | | 185 | |
---|
186 | }, | 186 | }, |
---|
187 | showOne: function(model) { | 187 | showOne: function(model) { |
---|
188 | if(model.get('how').isNew === undefined) { | | if(model.get('how').isNew === undefined) { |
---|
189 | console.log(model); | | console.log(model); |
---|
| | 188 | if(model.get('how').isValid === undefined) { | 190 | model.set({'how': new How(model.get('how'))}); | 189 | model.set({'how': new How(model.get('how'))}); |
---|
| | 190 | console.log(model); |
---|
191 | } | 191 | } |
---|
192 | var view = new CommentView({model:model}); | 192 | var view = new CommentView({model:model}); |
---|
193 | $(this.el).append(view.render().el); | 193 | $(this.el).append(view.render().el); |
---|