Skip to content

Instantly share code, notes, and snippets.

@rightson
Created June 24, 2012 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rightson/2985373 to your computer and use it in GitHub Desktop.
Save rightson/2985373 to your computer and use it in GitHub Desktop.
Backbone JS Router example
var myRouter = Backbone.Router.extend({
routes: {
":foo": "func1",
":foo/:bar" : "func2",
"*action" : "funcU"
},
func1: function(p1) {
alert('func1: '+p1);
console.log('func1: '+p1);
},
func2: function(p1, p2) {
alert('func2: '+p1 + ',' + p2);
console.log('func2: '+p1 + ',' + p2);
},
funcU: function(a) {
if (a !== '') {
alert('funcU: '+a);
console.log('funcU: '+a);
}
}
});
new myRouter();
Backbone.history.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment