我使用的是已$ .dialog呼吁这是$ EL的复合视图。
然后,将复合视图清单收集的物品。
现在,我已经尝试过多种方式来呈现收集物品:从之前的复合视图外并将其连接到视图,该视图里面取,从我的服务器脚本等预加载收集后取...
一切似乎工作,但会出现同样的问题..
一旦复合视图看到的这个集合,它调用它自己的再初始化函数...
我完全理解渲染功能将被要求收集复位或增加......但初始化??? 我绝对不知道为什么会这样。
showCustomFieldSelect: function(e){
log('triggered');
e.preventDefault();
var cl = new AustApp.Collections.CustomField;
var select = new AustApp.Views.AvailableCustomFieldsList({
el: "#available-custom-fields-popup",
collection: cl
});
cl.fetch();
cl.once("reset", function(){
// this bind was
// previously used for creating the view
// or calling render functions directly
// amongst numerous efforts to debug
}, this);
},
MyApp.Views.AvailableCustomFieldsList = function(){
var AvailableCustomFieldsList = Backbone.Marionette.CompositeView.extend({
template: "#available-contact-list-custom-field-list-js",
tag: "div",
itemView: AustApp.Views.AvailableCustomFieldsListItem,
emptyView: AustApp.Views.EmptyAvailableCustomFieldsListItem,
itemViewContainer: "ul",
templateHelpers: viewHelpers,
initialize: function(){
log('init called'); // called twice?????
this.render();
this.$el.dialog({
title: "Available Custom Fields",
width: '600px',
modal: true,
dialogClass: "round",
});
},
/* stuff */
});
return AvailableCustomFieldsList;
}();
任何帮助赞赏,因为我狼狈