当模型被销毁时,模型集合不会发出“同步”事件。文档似乎相反。这是我的代码片段:
var MyModel = Backbone.Model.extend({ id: 1, val: "foo" });
var MyCollection = Backbone.Collection.extend({ model: MyModel, url: '/api/models' });
var myCollection = new MyCollection();
myCollection.on('sync', function () { console.log('synced!'); });
myCollection.on('remove', function () { console.log('removed!'); });
myCollection.fetch(); // => outputs synced!
// .. wait for collection to load
myCollection.at(0).destroy(); // => outputs removed! but *NOT* synced!
如果我理解得很好,文档说“销毁”事件应该冒泡到集合中并发出一个“同步”事件。上面代码中的集合是否应该发出“同步”事件?