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();
    });

Get Better Backbone Applications with MarionetteJS now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.