0
由於某種原因ItemView不呈現。這裏是我的設置:骨幹和木偶,ItemView沒有渲染,怎麼樣?
控制器
test: function() {
require(['application', 'collections/collection-test', 'views/collection/view-test'], function (App, CollectionTest, ViewTest) {
var collectionTest = new CollectionTest();
App.regionTest.show(new ViewTest({
collection: collectionTest
}));
});
},
集合視圖
define(['backbone','views/item/itemview-test'],
function (Backbone, ItemviewTest) {
'use strict';
return Backbone.Marionette.CollectionView.extend({
tagName: 'ul',
initialize: function() {},
itemView: ItemviewTest,
ui: {},
events: {},
/* on render callback */
onRender: function() {
console.log(this.$el);
}
});
});
項目視圖
define(['backbone','hbs!tmpl/item/itemview-test_tmpl'],
function (Backbone, ItemviewTestTmpl) {
'use strict';
return Backbone.Marionette.ItemView.extend({
tagName: 'li',
initialize: function (options) {},
template: ItemviewTestTmpl,
ui: {},
events: {},
onRender: function() {
console.log(this.$el);
},
});
});
我可以看到被添加到該地區<ul></ul>
,而不是li
我可以渲染li
如果我'views/item/itemview-test'
INT EH控制器取代'views/collection/view-test'
,但現在我不會得到ul
另外,如果我console.log(new ItemviewTest())
集合中,我可以看到ItemView
對象與$el:'li'
標籤,但由於某種原因,它不會被添加到HTML
任何想法?