Reputation: 710
I have a Backbone application and I would like to remove the query string from parameters passed to the function.
These are some of the routes:
routes:
'': 'home'
'categories/:id/:sid(/)': 'subcategories'
'categories/:id(/)': 'categories'
Now, in categories
(or subcategories
) function, the last parameter also includes the query string, which I don't want.
I have tried the folowing:
but for an url like categories/1?page=2
, :id
is 1?page=2
.
How can I remove what follows ?
?
I am aware of backbone-query-string, but I don't want to use it.
Upvotes: 1
Views: 830
Reputation: 66
I think there is one way to handle this. If you visit the link(categories/1?page=2 or categories/1),
Write router like this:
'categories/:id\?:page' : 'categories'
'categories/:id' : 'categories'
categories: function(id){}
The id parameter will be the '1', and the page will be the 'page=2', but you can deprecate it.
Please notice the sequence of two routers
Upvotes: 1