Well, you can't have a parameter segment in your root url in Backbone.History
.
Some source code from Backbone.History.getFragment that is used to get the url-fragment to match routes to and extract variables from (I laid it out a bit differently)
if (!fragment.indexOf(this.options.root)) {
fragment = fragment.substr(this.options.root.length);
}
This piece of code is where every single Router.navigate
call ends up to (unless { trigger: false }
is applied). So what happens that if the fragment contains your root url defined with the start
-function, the fragment will be replaced with a substring of the original fragment that has the root conveniently left out. So your root url won't be even taken into consideration when the variables are picked away from the fragment.
so there is NO way to get variables into the root URL, because, by definition, the root url is just a pointer for Backbone.History in case your application is not served from the root url of your domain. Here's the quote:
If your application is not being served from the root url / of your domain, be sure to tell History where the root really is...
So if your application is not being served from /orders/12345/items
and /orders/78342/items
then I suggest that you don't try to tell your router that it is. Instead, serve it from /
and then set up the routes normally:
routes: {
'orders/:id/items': 'item'
}
Hope this clears things up!