【发布时间】:2013-04-23 22:20:03
【问题描述】:
所以,我不确定我是否完全理解应该如何触发此回调。如果您采用准系统模型、集合和视图:
PatchModel = Backbone.Model.extend({});
PatchCollection = Backbone.Collection.extend({model: PatchModel});
PatchView = Backbone.Marionette.ItemView.extend({template:'#patchview'});
PatchCollectionView = Backbone.Marionette.CollectionView.extend({
itemView:PatchView
,onItemAdded: function(itemView){
console.log("item was added");
}
});
然后像这样实例化它们:
Patch0 = new PatchModel({});
Patch1 = new PatchModel({});
Patches = new PatchCollection();
PatchesView = new PatchCollectionView({collection:Patches,el:"dom_id"});
Patches.add(Patch0);
PatchesView.render();
Patches.add(Patch1);
PatchesView onItemAdded 回调永远不会触发。嗯……
【问题讨论】:
-
只是好奇你为什么要添加空模型?
-
在发布之前,我删除了该示例不需要的所有内容,并确保它仍然以同样的方式失败。
标签: marionette