Skip to content

Instantly share code, notes, and snippets.

@gurdotan
Created October 5, 2013 13:39
Show Gist options
  • Save gurdotan/6841071 to your computer and use it in GitHub Desktop.
Save gurdotan/6841071 to your computer and use it in GitHub Desktop.
// Define a router for the games sub-application
var GamesRouter = Backbone.Router.extend({
routes: {
"": "root",
"games": "index",
"games/:id": "showGame"
},
root : function() { /*...*/ },
index : function() { /*...*/ },
showGame : function(id) { /*...*/ }
}
// Define a router for the storefronts sub-application
var StorefrontsRouter = Backbone.Router.extend({
routes: {
"games/:gameId/storefronts": "showStorefronts"
},
showStorefronts : function(gameId, storefrontId) { /*...*/ },
}
// Instantiated an instace of each router
// You can choose to keep references to your routers if necessary
new GamesRouter();
new StorefrontsRouter();
// Finally start Backbone's global history object
Backbone.history.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment