javascript - Backbone - NestedModels - Nested sets not firing "change" -


i using backbone nested plugin. wrote binding :

var view = backbone.view.extend({     initialize: function(params) {         this.model.bind('change', _.bind(this.rerender, this));     } 

the model passed view declared this, outside of view in global scope :

newmodel = new backbone.nestedmodel(jsondata); 

when write newmodel.set("prop", "value") triggers change , fires rerender

but when write newmodel.set("prop.prop", "value") doesn't trigger "change" if prop.prop existed. means value change isn't detected.

but new value detected: newmodel.set("newprop.newprop", "value") triggers change

nested gets work.

i can newmodel.get("prop.prop") returns value

now, if listen specific property work :

this.model.bind('change:prop.prop', _.bind(this.rerender, this)); } //fires rerender 

according plugin docs, listening "change" should fire change in case :

// fire when 'name.middle.initial' set or changed

user.bind('change', function(model, newval){ ... }); 

but doesn't. did wrong

what if try delegating event view using listen to?

points out:
- can pass context param 4th don't need bind callback function make code bit slower due unnecessary function call.

eg

var view = backbone.view.extend({     initialize: function(params) {         this.listento(this.model, "change", this.rerender, this);      } 

hope solution you.

cheers


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -