Results 1 to 10 of 12

Thread: Catching bubbled events in controllers

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha Premium Member
    Join Date
    Apr 2009
    Posts
    104
    Vote Rating
    3
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha Premium Member
    Join Date
    Apr 2009
    Posts
    104
    Vote Rating
    3
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  5. #5
    Sencha Premium Member
    Join Date
    Apr 2009
    Posts
    104
    Vote Rating
    3
      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
      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?

Posting Permissions

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