Created
April 28, 2012 14:57
-
-
Save ianstormtaylor/2519665 to your computer and use it in GitHub Desktop.
Enhanced Backbone.Router route function to handle trailing slashes and query strings.
This file contains hidden or 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
// Enhanced route function that automatically binds variant routes. | |
route : function (route, name, callback) { | |
var variants = [ | |
route, | |
route + '/', | |
route + '?:querystring', | |
route + '/?:querystring' | |
]; | |
// Bind a route for each of the variants. | |
for (var i = 0, rut; rut = variants[i]; i++) { | |
Backbone.Router.prototype.route.call(this, rut, name, callback); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment