I am using Backbone.js and I have a router. this is my routes property of the router:
routes: {
"pagea": "pageafunc",
"pageb": "pagebfunc",
"pagec": "pagecfunc",
}
is it possible to add a route that looks like this:
"mypath/*subroute": function(subroute) {
//do somethong
}
?
Nope, the
routesobject can only have string values.If you want to pass your own callback, you need to set up the route programatically. For instance, in your router’s initialize function, you can do this:
That said, this can get very unreadable quickly, and it means that you have to scan through your initialize functions to know all of the routes you have defined, so storing all of the routes in the
routesobject is much cleaner. Or at least keep the route function body on the Router itself and keep the route paths in a separate section for readability.