javascript - How to change model and render Marionette view from another view -


i' ve got layoutview in marionette. give onrender method:

onrender: function() {                          this.showchildview("content", new canvasview({ model: this.model }));              this.showchildview("library", new libraryview());              this.showchildview("properties", new propertiesview({ model: this.model }));          }

in content there model, contains svg elements(for ex. line, ellipse...) properties. need change model in propertiesview. example need change line width or color , rerender "content" child view. how this? propertiesview consists of input sets. example:

line color: <input type="text" id="id_2" name="style" value= <%= linecolor %>>	

you can use backbone event system. every time set model change event fires.

in propertiesview can add events user interaction. on every input set content model:

ui: {     'style': 'input[name=style]' }, events: {     'input @ui.style': 'oninputstyle' }, oninputstyle: function(){     this.model.set('style', this.ui.style.val()); } 

and in canvasview subscribe them , change view accordingly:

modelevents: {     'change:style': 'onchangestyle' }, onchangestyle: function(){     this.$el.attr('style', this.model.get('style')); } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -