这是我的CompositeView:
define(["marionette", "lodash", "text!fonts/products/template.html",
'fonts/products/item-view', 'fonts/products/collection', 'fonts/products/model'],
function(Marionette, _, templateHTML, ProductItemView, ProductsCollection, ProductsModel) {
'use strict';
var ProductsView = Marionette.CompositeView.extend({
tagName: "div",
template: _.template(templateHTML),
childView: ProductItemView,
initialize: function() {
this.collection = new ProductsCollection({
model: ProductsModel
});
},
onRender: function() {
this.collection.fetch();
}
});
return ProductsView;
});
这是我的ItemView:
define(["marionette", "lodash", "text!fonts/products/item-view.html"],
function(Marionette, _, templateHTML) {
'use strict';
var ProductItemView = Marionette.ItemView.extend({
tagName: 'div',
template: _.template(templateHTML)
});
return ProductItemView;
});
即使渲染了CompositeView,即使在提取集合后孩子也不会渲染