O'Reilly logo

Getting Started with Backbone Marionette by Arturo Soto, Raymundo Armendariz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Splitting modules into multiple files

Sometimes a module is so long for a single file that we want to split the definition across multiple files. But it is pretty common for the subapplication modules to contain controllers, routers, and views, among others, so we do not want to put them all together in a file. This is made really simple by Marionette.js modules, so let's take a look.

The following is an example code from a controller file:

Books.module('HistoryApp', function (HistoryApp, App) {    
    HistoryApp.Controller = Marionette.Controller.extend({

    });
});

An example code from a router file is as follows:

Books.module('HistoryApp', { startWithParent: false, define: function (HistoryApp, App, Backbone, Marionette, $, _) { var Router = Backbone.Router.extend({ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required