admin管理员组文章数量:1434921
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()
.
本文标签: javascriptModel change event order in backbone jsStack Overflow
版权声明:本文标题:javascript - Model change event order in backbone js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745625336a2666934.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论