Results 1 to 4 of 4

Thread: Multiple listeners on single route

  1. #1
    Sencha User
    Join Date
    Jul 2013
    Posts
    29
    Answers
    2

    Default Multiple listeners on single route

    Hi,

    I've been working on an app based on sencha for a client and have run into an issue that shouldn't exist.

    Basically i'm using routes to navigate through the app. One of such routes is "#recent".
    I've setup 2 controllers with this route in their config.routes settings to do things when the user navigates to /#recent.

    The problem is that ony one of the functions bound to the "#recent" route is being called, based on the order i've defined the controllers in the app definition.
    If i change the order of the two controllers the other controller function will fire, but never both (the expected behaviour). The switching tells me there's nothing wrong with my code per se.

    Is this normal, or is there something that is should be aware of when trying the above?

    As for example code, i just have 2 controllers with the following config:
    Code:
    config: {        
        routes: {
            'recent': 'testFunction'
        }
    },
    
    testFunction: function() { console.log('foo'); }
    and

    Code:
    config: {        
        routes: {
            'recent': 'testFunctionTwo'
        }
    },
    
    testFunctionTwo: function() { console.log('bar'); }
    The documentation i've read tells me both should be triggered:
    If you have multiple controllers that match the same hash token, the order of execution will be the order defined in the Application instance in the controllers array
    as found here https://www.sencha.com/blog/how-to-use-routing-in-your-ext-js-5-apps/

    I
    f anyone has a tip, it's welcome!

  2. #2
    Sencha User
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Can you share a runnable example that demonstrates the issue? https://fiddle.sencha.com

    When I try to replicate, both routes fire as expected. See here:

    https://fiddle.sencha.com/fiddle/s88/preview#recent

    Thanks!
    Joel

  3. #3
    Sencha User
    Join Date
    Jul 2013
    Posts
    29
    Answers
    2

    Default

    Thanks for your answer!
    I've tested your Fiddle and it worked ofcourse. This is the expected behaviour after all.

    I'm thinking it's a difference in Sencha/ExtJS versions that causes the change in behaviour.
    I'm using sencha touch 2.4.2 with sencha CMD 6. Maybe this topic is in the wrong category, but i thought it was a ExtJS issue.

    I've now been able to create a fiddle which displays this error/weird behaviour. See https://fiddle.sencha.com/fiddle/s95
    When calling the route "recent" only one route function gets called.
    I would expect both to be called.

    Any help is appreciated!
    Last edited by swigle; 17 Aug 2015 at 12:53 AM. Reason: layout not saved by quickreply.

  4. #4
    Sencha User
    Join Date
    Jul 2013
    Posts
    29
    Answers
    2

    Default

    Update: I've just opened my own link to the fiddle which doesn't work, weirdly. If you click on "Open in fiddle" the example does work, but it loads with ExtJS 6 as standard. Both route listeners get called.

    If you change the framework to sencha 2.4, the fiddle also works but only one route listener gets called.

Similar Threads

  1. Replies: 3
    Last Post: 15 Mar 2015, 8:50 PM
  2. Changing the default 'multiple route' delimiter?
    By twasink in forum Ext 5: Q&A
    Replies: 3
    Last Post: 8 Aug 2014, 3:25 AM
  3. Replies: 0
    Last Post: 30 Dec 2013, 12:59 AM
  4. Replies: 3
    Last Post: 6 Aug 2013, 12:31 AM
  5. Replies: 3
    Last Post: 15 Dec 2011, 2:48 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •