Created
April 20, 2012 17:24
-
-
Save ovaillancourt/2430438 to your computer and use it in GitHub Desktop.
Router example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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