mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Merge branch 'master' of github.com:documentcloud/backbone
This commit is contained in:
@@ -990,6 +990,7 @@
|
||||
// routes can be defined at the bottom of the route map.
|
||||
_bindRoutes: function() {
|
||||
if (!this.routes) return;
|
||||
this.routes = _.result(this, 'routes');
|
||||
var route, routes = _.keys(this.routes);
|
||||
while ((route = routes.pop()) != null) {
|
||||
this.route(route, this.routes[route]);
|
||||
|
||||
@@ -529,4 +529,27 @@ $(document).ready(function() {
|
||||
Backbone.history.checkUrl();
|
||||
});
|
||||
|
||||
test("#2255 - Extend routes by making routes a function.", 1, function() {
|
||||
var RouterBase = Backbone.Router.extend({
|
||||
routes: function() {
|
||||
return {
|
||||
home: "root",
|
||||
index: "index.html",
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
var RouterExtended = RouterBase.extend({
|
||||
routes: function() {
|
||||
var _super = RouterExtended.__super__.routes;
|
||||
return _.extend(_super(),
|
||||
{ show: "show",
|
||||
search: "search" });
|
||||
}
|
||||
});
|
||||
|
||||
var router = new RouterExtended();
|
||||
deepEqual({home: "root", index: "index.html", show: "show", search: "search"}, router.routes);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user