Sencha Ext JS 6 - How to replace Route Controller

242 Views Asked by At

I'm dynamically loading a new Route Controller and initializing it. It works fine and the new routes take effect.

However, it looks like the old route controller is still loaded as well.

In both controllers there is the following listener for unmatched route and all of them execute.

    listen : {
        controller : {
            '#' : {
                unmatchedroute : 'onUnmatchedRoute'
            }
        }
    },

How can the route controller be replace with another one dynamically?

1

There are 1 best solutions below

0
Doctor.Who. On BEST ANSWER

Do not use listen : { controller: { '#': { unmatchedroute

Use on and un:

// addListener
MyApp.app.on('unmatchedroute', someFunction);
//or
Ext.on('unmatchedroute', someFunction);


// removeListener
MyApp.app.un('unmatchedroute', someFunction);
//or
Ext.un('unmatchedroute', someFunction);