javascript - Model change event order in backbone js - Stack Overflow

Is it guaranteed that 'change:property' events are always fired before 'change' eve

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 badges
Add a ment  | 

1 Answer 1

Reset to default 5

Short 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

相关推荐

  • javascript - Model change event order in backbone js - Stack Overflow

    Is it guaranteed that 'change:property' events are always fired before 'change' eve

    22天前
    60

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信