Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Routes extjs before parameter after?

I'm developing an extjs application with Sencha Cmd v6.5.3.6 and modern toolkit. My app always handles the url with parameters, example:

http:localhost:1841/#users?language=es&tenant=Number

I use the language parameter to identify the location and the tenant for the current user login in the app.

How can I define a route that handles urls and parameters inside it?

For the last example, how can I implement a route for the next url?:

http:localhost:1841/#users?language=es&tenant=1, define a route that reads the token "users" but ignore the parameters "language" and "tenant".

routes : {
    'users?...' : 'onUsers'
},

onUsers: function(){
  ....
}
like image 920
Carlos Ramirez Avatar asked Dec 30 '25 23:12

Carlos Ramirez


1 Answers

You have few options really. The recommended one as per Sencha is to set your route as:

routes : {
    'users/:language/:tenant' : 'onUsers'
},

onUsers: function(language, tenant){
  ....
}

Another one would be to go your current way but to do this:

routes : {
    'users/:params' : 'onUsers'
},

onUsers: function(params){
  ....
}

and then to deal with the "recovering" the parameters from that string you would have in params.

like image 127
Akrion Avatar answered Jan 02 '26 01:01

Akrion