Browse files

Keep routes indexed by route name for retrieval later.

  • Loading branch information...
1 parent e09408b commit 33e9637092945b38eae43145d5fc80aed271eb84 @fblee fblee committed Jan 29, 2013
Showing with 5 additions and 0 deletions.
  1. +5 −0 js/lib/router.js
View
5 js/lib/router.js
@@ -61,16 +61,21 @@ _.extend(components.RapportiveRouter.prototype, /*Events, */ {
return decodeURIComponent(bit).replace(/\+/g, ' ');
},
+ routes_by_name: {},
+
// Manually bind a single named route to a callback. For example:
//
// this.route('search/:query/p:num', 'search', function(query, num) {
// ...
// });
//
route: function (route, name, callback) {
+ this.routes_by_name[name] = route;
+
if (!_.isRegExp(route)) {
route = this._routeToRegExp(route);
}
+
if (!callback) {
callback = this[name];
}

0 comments on commit 33e9637

Please sign in to comment.