Skip to content

Instantly share code, notes, and snippets.

@ovaillancourt
Created April 20, 2012 17:24
Show Gist options
  • Save ovaillancourt/2430438 to your computer and use it in GitHub Desktop.
Save ovaillancourt/2430438 to your computer and use it in GitHub Desktop.
Router example
//The application model itself.
var Router = Backbone.Router.extend({
//Attributes
routes : {
//Home sweet home!
'home' : 'home',
// //People
'people' : 'people',
'people/:uid' : 'people_profile',
},
//Methods
initialize : function(options){
this.model = null;
},
setModel : function(model){
this.model = model;
Backbone.history.start();
},
home : function(){
this.model.get('appWindow')
.swapView('home');
},
people: function(){
this.model.get('appWindow')
.swapView('people')
.swapView('peopleSummary');
},
people_profile : function(uid){
this.model.get('appWindow')
.swapView('people')
.swapView('peopleProfile',uid);
}
});
module.exports = new Router();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment