Skip to content

Instantly share code, notes, and snippets.

@mxriverlynn
Created February 3, 2012 18:37
Show Gist options
  • Save mxriverlynn/1731648 to your computer and use it in GitHub Desktop.
Save mxriverlynn/1731648 to your computer and use it in GitHub Desktop.
stages of backbone app startup
App = {
init: function(){
// app initialization and startup goes here
}
}
App.init();
Backbone.Router.extend({
routes: {
"image/:id": "imageById"
},
imageById: function(id){
var image = imageCollection.get(id);
App.showImage(image);
}
});
Backbone.Router.extend({
routes: {
":roomname": "chatroom"
},
chatroom: function(roomname){
ChatApp.enterRoom(roomname);
}
});
App = new Backbone.Marionette.Application();
App.addInitializer(function(){
// add some app initialization code, here
});
App.addInitializer(function(){
// more initialization stuff
// for a different part of the app
});
// run all the initializers and start the app
App.start();
App = new Backbone.Marionette.Application();
/* ... initializers go here ... */
// contextual startup
App.on("initialize:after", function(){
Backbone.history.start();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment