Marionette.js CompositeView不会渲染儿童

时间:2015-06-30 18:22:34

标签: javascript backbone.js marionette

这是我的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,即使在提取集合后孩子也不会渲染

0 个答案:

没有答案