extjsextjs6.5

Sencha Ext JS 6 - How to replace Route Controller


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?


Solution

  • 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);