public
Last active

stages of backbone app startup

  • Download Gist
1.js
JavaScript
1 2 3 4 5 6 7
App = {
init: function(){
// app initialization and startup goes here
}
}
 
App.init();
2.js
JavaScript
1 2 3 4 5 6 7 8 9 10
Backbone.Router.extend({
routes: {
"image/:id": "imageById"
},
imageById: function(id){
var image = imageCollection.get(id);
App.showImage(image);
}
});
3.js
JavaScript
1 2 3 4 5 6 7 8 9
Backbone.Router.extend({
routes: {
":roomname": "chatroom"
},
chatroom: function(roomname){
ChatApp.enterRoom(roomname);
}
});
4.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13
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();
5.js
JavaScript
1 2 3 4 5 6 7 8
App = new Backbone.Marionette.Application();
 
/* ... initializers go here ... */
 
// contextual startup
App.on("initialize:after", function(){
Backbone.history.start();
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.