- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
因此,我不确定我是否完全理解应该如何触发此回调。如果您采用准系统模型、集合和 View :
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 回调永远不会触发。嗯……
最佳答案
看起来文档已经过时了。您应该使用 onAfterItemAdded 或 onBeforeItemAdded
这在 v1.0.0-rc2 中已更改
*BREAKING: * Changed the
item:added
event tobefore:item:added
andafter:item:added
这是对您的示例进行了修改的 fiddle 。 http://jsfiddle.net/puleos/axJg4/
var PatchCollectionView = Backbone.Marionette.CollectionView.extend({
itemView: PatchView,
initialize: function() {
_.bindAll(this);
},
onAfterItemAdded: function(itemView){
console.log("item was added");
},
onRender: function(){
console.log("render");
}
});
关于marionette - 将模型添加到 Marionette CollectionView 的集合中不会触发 onItemAdd 回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16180159/
我在使用 onItemAdd 时遇到 selectize.js 问题构造函数的参数 ( https://github.com/brianreavis/selectize.js/blob/master/
长话短说 为了更清楚,我想在 onItemAdd 函数内访问所选 JSON 对象中的所有数据。现在我只能通过配置变量访问 _id 和 name。 好的,所以我有一个有效的 Selectize.js 函
使用 Selectize.js,我试图在不触发 onItemAdd 事件的情况下初始化动态预选列表项之一。在以下代码中,即使 silent 参数为真,也会触发事件: $(function () {
因此,我不确定我是否完全理解应该如何触发此回调。如果您采用准系统模型、集合和 View : PatchModel = Backbone.Model.extend({}); PatchCollectio
我是一名优秀的程序员,十分优秀!