I am beginner in Backbone development and I am trying to develop a Lifecycle management using Backbone. The project contains four main tabs, with subtabs in every tab. I created the main tabs using controllers, models and views etc. I also added navigation slider
That is all working fine, but I am confused about how to load the sub tabs within a main tab. My main question is, where do I start the controller for the sub tabs? Is it from the initialize method of the main tab's controller?
Code Overview: - Main controller loads the collection and models for each tab - Main controller shows the view of each tab when the main tab is clicked
// Declare pages collection
var mainpages = new TST.Collections.Pages([ new SCL.Models.Page({
id : 1,
name : "Main Tab1",
route : "!/tab1",
_controller : TST.Controllers.Tab1
}), new SCL.Models.Page({
id : 2,
name : "Main Tab2",
route : "!/tab2",
_controller : TST.Controllers.Tab2
}) ], {
current : 1
});
// show the main layout
var layout = new TST.Layouts.Main({
collection : mainpages
});
this.options.region.show(layout);
// show the menu
var menu = new TST.Views.Nav({
collection : mainpages
});
layout.menu.show(menu);
Regions are declared in Main layout. And shows each tab on tab click using -> self.content.show(options.view, self.options.collection.goRight); where self = this
The controllers of each tab look like this
SCL.Routers.Tab1= Backbone.Marionette.AppRouter.extend({
appRoutes : {
"!/request" : "start"
}
});
SCL.Controllers.Tab1= TST.Framework.Controller.extend({
initialize : function(options) {
this.layout = new TST.Layouts.Tab1();
this.router = new TST.Routers.Tab1({
controller : this
});
},
start : function() {
app.vent.trigger("page:change", {
view : this.layout
});
}
});
So now, How can I load a sub tabs under the Tab1??
Please share your ideas and help me... Thanks in advance!