Is it guaranteed that ‘change:property’ events are always fired before ‘change’ events?
Here is an example:
MyModel = Backbone.Model.extend({
property1: 'value1',
property2: 'value2'
});
var myModel = new MyModel();
myModel.bind('change:property1', function () { alert("change pty1"); })
.bind('change', function () { alert("change"); })
.bind('change:property2', function () { alert("change pty2"); });
Is it guaranteed that the function bound to ‘change’ will be fired last?
Short answer: yes
Looking at the source code, yes the
individual:changesare fired in the loop, and after that, if there was any change, the mainchangeevent will fire. None of these will fire if you passedsilent: true.The order of the individual change events firing depends on the order of the attributes passed to
.set().