【发布时间】:2019-08-05 20:21:33
【问题描述】:
当集合在初始化函数中定义时,Marionette 集合事件不会触发。 例如:
collectionEvents: {
update: 'onCollectionUpdate',
change: 'onCollectionChange',
error: 'onCollectionError',
},
initialize(opts) {
this.collection = new ListCollection({...});
}
但是当集合被定义为compositeView 类的一个属性时它可以正常工作
collection: new ListCollection({...}),
collectionEvents: {
update: 'onCollectionUpdate',
change: 'onCollectionChange',
error: 'onCollectionError',
},
是否有这个原因我需要在初始化函数中定义集合,因为我有数据被传递给集合需要的构造函数
【问题讨论】:
标签: javascript model-view-controller backbone.js marionette