When I pass {"silent":true} while setting an attribute in a Backbone model, why doesn’t that just suppress the change:attribute event? What is the advantage of firing that event the next time an attribute is changed?
Update
Backbone 0.9.10 changed the behavior of passing { "silent": true }. From the changelog:
Passing
{silent:true}on change will no longer delay individual
“change:attr” events, instead they are silenced entirely.
Browse the changelog here
This has confused me for some time as well.
The reason is that {silent:true} does not mean “Do everything as normal, but just don’t trigger the event”.
From various comments and answers by @jashkenas, what it seems to mean is “simply change the attribute value (and add it to the ‘changedAttributes’ hash), but defer all other “change-related” activities until later”.
‘silent’ doesn’t prevent the
changeevent for that/those properties, it simply queues up the ‘announcement’ until the nextchangeevent is triggered.So, its probably better named something like
defer.Relevant information:
https://github.com/documentcloud/backbone/pull/850
https://github.com/documentcloud/backbone/issues/870
Update 4/7/2013
Note: I have not tested this to confirm behavior, this is just based on my reading of the release notes…
As of Backbone 0.9.10, the behavior described above has changed. In that version (and newer),
silent:truesuppresses thechange:attrevents entirely – not just delays them.http://backbonejs.org/#changelog