How should I download my web application using Backbone.Marionette and requireJs

Say my application works, but I love learning and finding the best way to do things.
I really appreciate this post about Reducing Backbone Routers to Nothing More Than Setting Up .
And the next bbclonemail , which is not used, requires.

In fact, my implementation is a monolithic block ( app.js , router.js ).

Here are my questions:
1) What should router module router.js ?
2) How to remove The Callback Functions from router.js ?
3) What should app module app.js ?
4) How to disable app.js in many other applications (for example: main, tasks, projects).


app.js

 // app.js define([ 'router' // some modules ], function (router, Backbone, HeaderView) { "use strict"; var myApp = new Backbone.Marionette.Application(); myApp.addRegions({ header: '#header', sidebar: '#sidebar', mainColumn: '#main-column', rightColumn: '#right-column' }); myApp.initHeader = function () { var headerView = new HeaderView(); myApp.header.show(headerView); } // many others many views myApp.start(); myApp.initialize = function() { router.initialize(); Backbone.history.start(); } return myApp; }); 

router.js

 // router.js define([ // some modules ], function (Backbone) { "use strict"; var AppRouter = Backbone.Marionette.AppRouter.extend({ routes: { tasks: 'tasks', projects: 'projects', // many others keys/values '*defaults': 'home' }, getApp: function () { var mainApp; require(['js/app'], function (app) { mainApp = app; }); return mainApp; }, home: function() { var app = this.getApp(); app.initHeader(); app.initSidebar(); app.initTaskDetails(); }, // many others callbacks }); var initialize = function() { new AppRouter; }; return { initialize: initialize }; }); 
+8
requirejs marionette backbone-routing
source share
1 answer

For the Router part, you should do the following:

router.js

 // router.js define([ 'rooterController' // some modules ], function (Backbone, rooterController) { "use strict"; var AppRouter = Backbone.Marionette.AppRouter.extend({ routes: { tasks: 'tasks', projects: 'projects', // many others keys/values '*defaults': 'home' } }); return new AppRouter({constroller: rooterController}) }); 
+1
source share

All Articles