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?
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?
Share Improve this question asked Oct 27, 2011 at 11:42 nakhlinakhli 4,0696 gold badges39 silver badges62 bronze badges1 Answer
Reset to default 5Short answer: yes
Looking at the source code, yes the individual:changes
are fired in the loop, and after that, if there was any change, the main change
event will fire. None of these will fire if you passed silent: true
.
The order of the individual change events firing depends on the order of the attributes passed to .set()
.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745625337a4636769.html
评论列表(0条)