Routes And Controllers In Marionette.js
Im new the Marionette.js. Im currently implementing routes and controllers. In my App.js, I have: App.appRouter = new Router({ controller:new AppController() }); I
Solution 1:
It is recommended that you divide your controller objects into smaller pieces of related functionality and have multiple routers / controllers, instead of just one giant router and controller.
So do this:
varAppController = Backbone.Marionette.Controller.extend({
initialize:function (options) {
},
customAction: function() {
console.log('in customAction');
}
});
varGenericController = Backbone.Marionette.Controller.extend({
initialize:function (options) {
},
getGeneric: function(){
console.log('in getGeneric');
}
});
App.appRouter = newMarionette.AppRouter({
controller:newAppController(),
appRoutes: {
"custom": "customAction"
}
});
App.genericRouter = newMarionette.AppRouter({
controller: newGenericController(),
appRoutes: {
"generic": "getGeneric"
}
});
Here's a jsbin, but it doesn't work however.
Post a Comment for "Routes And Controllers In Marionette.js"