BackboneJS How to merge multiple subviews into one view

120 Views Asked by At

How can I merge 4 subviews into 1 main view? I use the 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;
});

Should I remove the this.insertView on each collection?

Can anyone help me out?

Thanks in advance...

0

There are 0 best solutions below