I want to have a kind of RESTful URL structure like below:
- /accounts
- /accounts/account/123
I've set up my routes as such:
MyRouter = Backbone.Router.extend({ routes : { '/accounts': 'accounts', '/accounts/account/:account': 'account', }, accounts: function() { console.log('accounts CALLED'); }, account: function() { console.log('account CALLED'); }, });
The problem, is when I go to /accounts/account/123 , both accounts() and account() get called (as the URL matches both routes). I tried a route such as /accounts$, but it doesn't look like it's supported in the routes hash.
Is there a way to accomplish this? Would a manual router.route(route, name, callback) work instead (although I really prefer not to do that).