Hybrid View

  1. #1
    Sencha Premium Member
    Join Date
    Apr 2009
    Posts
    104
    Vote Rating
    0
    jej2003 is on a distinguished road

      0  

    Default Unanswered: Catching bubbled events in controllers

    Unanswered: Catching bubbled events in controllers


    I have a setup where I am bubbling events that I'd like to catch in my controller. I have something like this

    Code:
    this.control({
                'mypanel': {
                    customevent : function(cmp){...}
    where the customevent is bubbled up from a subcomponent of mypanel, but this doesn't get caught in the controller. If I do this

    Code:
    this.control({
                'mypanel > subpanel': {
                    customevent : function(cmp){...}
    it works fine. Also if I just add some listeners to make sure things are firing properly by doing
    Code:
    var myPanel = Ext.create('mypanel', {
      listeners : {
        customevent : function(){
           alert('boo');
        }
      }
    });
    I see the method being called. Should this work?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,632
    Answers
    3452
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I personally would go with 'mypanel > subpanel' or 'mypanel subpanel'. The event is firing only on the subpanel but bubbleEvents walks up the hierarchy to see if it has a listener.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha Premium Member
    Join Date
    Apr 2009
    Posts
    104
    Vote Rating
    0
    jej2003 is on a distinguished road

      0  

    Default


    hmm....so the problem is I don't know the type of the components that are being added, they are driven by dynamically created menu items. Does the component query support all sub classes? So if I said panel and my custom component was a subclass of panel would that work?

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,632
    Answers
    3452
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by jej2003 View Post
    hmm....so the problem is I don't know the type of the components that are being added, they are driven by dynamically created menu items. Does the component query support all sub classes? So if I said panel and my custom component was a subclass of panel would that work?
    Yes it will.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha Premium Member
    Join Date
    Apr 2009
    Posts
    104
    Vote Rating
    0
    jej2003 is on a distinguished road

      0  

    Default


    nevermind, had a dumb problem, looks like it works perfectly, thanks Mitchell

  6. #6
    Sencha User
    Join Date
    Mar 2010
    Posts
    4
    Vote Rating
    0
    pao is on a distinguished road

      0  

    Default


    Then, this code works?

    Code:
    this.control({           
     'mypanel': {              
        customevent : function(cmp){...}
    ...
    I have same problem, listeners don't catch bubbled events.

    Any suggestion?