O'Reilly logo

Better Backbone Applications with MarionetteJS by Joseph Zimmerman, Smashing Magazine

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

Chapter 13: Building a Foundation

Before we get into the meat and potatoes of the application, we should start with the basic structural and foundational pieces so the rest of our code has something to lean on. We’ll start off by creating our Application object.

Application

Create a file called QuizEngine.js and place it in the js folder. It’ll contain the following code:

js/QuizEngine.js

var QuizEngine = (function(){

    var Application = Marionette.Application.extend({});

    var application = new Application();

    application.addRegions({
        header: '[data-region=header]', // Not used right now
        body: '[data-region=body]',
        footer: '[data-region=footer]' // Not used right now
    });

    application.on('initialize:after', function() {
        Backbone.history.start();
    });

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