BackboneJS如何将多个子视图合并到一个视图中

时间:2014-05-14 12:34:06

标签: backbone.js backbone-layout-manager

如何将4个子视图合并为1个主视图?我使用Backbone.Layoutmanager

define(['app','backbone', 'modules/cars', 'modules/motorcycles', 'modules/bikes', 'modules/quads'],

function (App, Backbone, Cars, Motorcycles, Bikes, Quads){

    Motors.View = Backbone.View.extend({
        tagName: 'ul',
        beforeRender: function(){
            var carsCollection = new Cars.CarsCollection();
            this.insertView(new Cars.View({collection: carsCollection }));
            carsCollection.fetch();

            var motorcycleCollection = new Motorcycle.MotorcycleCollection();
            this.insertView(new Motorcycle.View({collection: motorcycleCollection}));
            motorcycleCollection.fetch();

            var bikesCollection = new Bikes.BikesCollection();
            this.insertView(new Bikes.View({collection: bikesCollection}));
            bikesCollection.fetch();

            var quadsCollection = new Quads.QuadsCollection();
            this.insertView(new Quads.View({collection: quadsCollection}));
            quadsCollection.fetch();

        }
    });

    return Motors;
});

我应该删除每个集合上的this.insertView吗?

任何人都可以帮助我吗?

提前致谢...

0 个答案:

没有答案