Commit 4caaa595b4adf4b39a1157139711635c42acb223

Fix existing content not updating

  Even with previous the bug was not fixed. Hopefully fixed now.
  • Diff rendering mode:
  • inline
  • side by side

mouchak/static/js/editor.js

109 _.bindAll(this);109 _.bindAll(this);
110 _.bind(this.render, this);110 _.bind(this.render, this);
111 this.editing = false;111 this.editing = false;
112 this.edit_idx = -1;
112 $('#page').remove();113 $('#page').remove();
113 $('#content-container').append(this.$el);114 $('#content-container').append(this.$el);
114 this.template = _.template($('#page-template').html());115 this.template = _.template($('#page-template').html());
169 var content = this.model.get('content')[idx];169 var content = this.model.get('content')[idx];
170 content = new M.types.model[content.type](content);170 content = new M.types.model[content.type](content);
171 this.editing = true;171 this.editing = true;
172 this.edit_idx = idx;
172 var contentview = new ContentView({model: content});173 var contentview = new ContentView({model: content});
173 contentview.render();174 contentview.render();
174 M.editor.contentview = contentview;175 M.editor.contentview = contentview;
183 data: ''183 data: ''
184 });184 });
185 this.editing = true;185 this.editing = true;
186 this.edit_idx = -1;
186 var contentview = new ContentView({model: content});187 var contentview = new ContentView({model: content});
187 contentview.render();188 contentview.render();
188 M.editor.contentview = contentview;189 M.editor.contentview = contentview;
195 }195 }
196 //console.log('updateContent in Pageview');196 //console.log('updateContent in Pageview');
197 var content = this.model.get('content');197 var content = this.model.get('content');
198 content.push(json);
198 if(this.edit_idx > -1) {
199 content[this.edit_idx] = json;
200 }
201 else {
202 content.push(json);
203 }
204
199 this.editing = false;205 this.editing = false;
206 this.edit_idx = -1;
200 //console.log('setting content in page: ', content);207 //console.log('setting content in page: ', content);
201 this.model.set({'content': content});208 this.model.set({'content': content});
202 this.render();209 this.render();