Jenya
Jenya

Reputation: 21

Route parameter disappears while acessing a route

I have routes:

routes: {
   "": "main",
   "!/order/:id": "order",
   "!/order": "order"
},

Then I access for example to http://mysite.ru/#!/order/21. But my URL changes to: http://mysite.ru/#!/order/

The number 21 is hiding. How to save this number in my URL?

Upvotes: 0

Views: 98

Answers (2)

Eric Guan
Eric Guan

Reputation: 15982

You can simplify your router by making the :id parameter optional, since your callback is the same for both order routes.

routes: {
   "": "main",       
   "!/order(/:id)": "order",
},

Upvotes: 2

BonifatiusK
BonifatiusK

Reputation: 2331

I think it is cascading. Try to set the general order routing first:

routes: {
   "": "main",       
   "!/order": "order",
   "!/order/:id": "order"
},

Upvotes: 3

Related Questions