[Question] updating the model/view content
Hi,
I'm writing a custom component where I want to modify the content of the component after it's dropped. I made a simple test by combining some examples I found somewhere:
view: defaultType.view.extend({
init() {
this.listenTo(this.model, 'active', this.doStuff); // listen for active event
},
doStuff() {
var randomHex = function() {
return '#' + Math.floor(Math.random()*16777216).toString(16);
};
// this is reflected on the canvas
this.model.set('style', {color: randomHex()});
// this is reflected only in the generated HTML
this.model.set('content', 'TEST');
}
The issue I have, as reflected in the comments above, is that updating the content doesn't reflect in the canvas, but when I extract the HTML from the editor to save it, the change is reflected. How can I make it so that the change to the model is reflected "live"? Or do I just have to also update the view's element myself?
Thanks!
Please ignore. I was able to make it work by adding a call to view.render()
@roytang this just helped me so much thanks for posting the answer
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.