Skip to content

jmfolds/browserify-marionette

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting Marionette AppRouter to work with Browserify

I am unable to get Marionette.AppRouter to fire using Browserify. Any help is much appreciated.

var $ = require('jquery');
var Backbone = require('backbone');
var Marionette = require('backbone.marionette');

var TestView = Marionette.ItemView.extend({
    el: 'body',
    template: '#test-template'
});

var Controller = Marionette.Controller.extend({
    initialize: function () {
        console.log('TestRouter controller initialize');
    },
    test: function (x, y, level) {
        var view = new TestView().render();
        console.log('Now we are routing!');        
    }
});

var TestRouter = Marionette.AppRouter.extend({
    initialize: function () {
        console.log('TestRouter initialize');
    },
    controller: new Controller(),
    appRoutes: {
        '': 'test',
        'test(/)': 'test',
        'test/:x': 'test'
    }
});

var App = new Marionette.Application();

App.on('start', function () {
    this.router = new TestRouter();

    if (Backbone.history) {
        Backbone.history.start();
        console.log('Backbone.history started');
    }
});

App.start();

To to build/serve the bundled/browserified code:

  • You'll need node.js, with gulp installed.
  • clone repo
  • cd /repo && npm install
  • gulp build to run browserify.
  • gulp watch to run browserify on file save.
  • gulp to run locally at localhost:8080

About

Test app using Marionette.AppRouter and Browserify

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published