I was updating my backbone version from 0.9.2 to 1.0 yet I've encountered a problem.
The model is not updating properly. It has delays in it. previously my code below works perfectly:
this.model({ attrib: true},{silent:true});
But after updating I removed the {silent:true}
and everything works perfectly. The model updates properly.
I've read something like this on Backbonejs.org
Passing {silent:true} on change will no longer delay individual "change:attr" events, instead they are silenced entirely.
I dont get entirely what the statement means.
About the meaning of the doc you quoted:
When you were doing (I guess the this.model
was an error) this.set({attr: value}, {silent: true})
, all the change events were just delayed until the next non-silent change. That is, if you were doing this.trigger('change')
(as of the last versions of jQuery/Backbone, this.change()
doesn't work anymore) or this.set('anotherAttr', anotherValue)
, a change:attr
event would have been triggered.
As of Backbone 1.0, this behavior has changed. When you're using the silent flag, you're not delaying the change:attr
event anymore, you're shutting it off completely.
So basically, to illustrate with a piece of code:
myModel.listenTo(myModel, 'change:attr', function() {alert();});
myModel.set('attr', true, {silent: true});
myModel.trigger('change');
// or myModel.set('anotherAttr', true);
will do an alert in Backbone prior 1.0, but not in Backbone 1.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With