3

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(){
  ....
}
SoConfused
  • 1,799
  • 3
  • 12
  • 18

1 Answers1

2

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.

Akrion
  • 18,117
  • 1
  • 34
  • 54
  • Thanks for answer my question, i found the regular expressions implementation to solve my question, i upload the route solution: ':type(/:args)?' and if the url has parameters: ':type/:id(/:args)?' – Carlos Ramirez Aug 24 '18 at 14:12