问题
Is it possible to register a route for /pages/*url but not for /pages/*url/edit/ where URL can be something like this foo/bar/and-so-on?
回答1:
router.route supports using a regex natively.
initialize: function(options) {
// Matches /117-a/b/c/open, passing "117-a/b/c" to this.open
this.route(/^(.*?)\/open$/, "open");
},
open: function(id) { ... }
来源:https://stackoverflow.com/questions/10270840/backbone-js-and-regex-routing