My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

{silent:true} in Backbone 1.0 version

Pedro Alvarado's photo
Pedro Alvarado
·Sep 2, 2019

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.