2014-05-07 25 views
0

现在我已经定义了一个集合,并绑定了添加和更改事件侦听器,但是当添加新模型时,将触发更改事件。如何避免当新模型被添加到骨干中的集合时触发更改事件?

collection.bind('add',addMethod); 
collection.bind('change',changeMethod); 

如何避免触发更改事件?

+2

当添加模型阻止事件触发时,您可以使用pass'{silent:true}'。 – agconti

+0

像这样使用它: collection.add(model,{silent:true})? – WangHongjian

回答

1

正如评论中所述,当您向收藏中添加某些东西时,请将silent-option添加到该功能调用中。有关更多信息,请查询Backbonejs reference

collection.add(someModel, {silent: true}); 
相关问题