Results 1 to 2 of 2

Thread: Custom Event Help

  1. #1
    Sencha Premium Member
    Join Date
    Sep 2008
    Posts
    710

    Default Custom Event Help

    Kinda new to custom events and having an issue getting a listener to work. Let's say I have component A which is to be a reusable paging paging toolbar. And component B is a product list that will consume two of these component A's abouve and below the product listing. What are the exact steps that I need to take to get component A to fire the event 'showMoreItems' such that component B can listen to and respond to the event?

    I have done the following things. First off, since the reusable comp A extends the panel which is a descendant of Observable, I get events by default so long as I set them up correctly (or so I think). So I have the following code pieces in comp A:
    Code:
        // Component Init
        initComponent: function () {
            Ext.apply(this, {
                items: [  
                  .....
                    {
                        xtype: 'button',
                        .....
                        handler: this.handleEvents
                    }
                ]
            });
    
            // Add component Events
            compA.superclass.initComponent.call(this);
            this.addEvents('showMoreItems');
        },
    
    .......
    
        , handleEvents: function(e){
            this.fireEvent('showMoreItems', e.type, e);
        }
    Then in comp B I have the following on the config of comp A:
    Code:
                    {
                        id: 'compA_InstanceName',
                        xtype: 'compA',
                        .....
                        listeners: {
                            showMoreItems: function (type, e) {   
                                alert('Listen Please!');
                            }                            
                        }
                    },
    I cannot get the listener to work. Debugging shows that compA's handleEvents method is getting called and the fireEvent method as well. So what am I missing here? Do I need to do something else like register the event?

    Appreciate ANY help here as I feel that I am close....thanks!

  2. #2
    Sencha Premium Member
    Join Date
    Sep 2008
    Posts
    710

    Default

    Dang it...was the ol' ownerCt that was getting me. Wan not firing the event on the proper container.

    Just needed:
    Code:
         this.ownerCt.addEvents('showMoreItems');

Similar Threads

  1. custom global event
    By tarik in forum Community Discussion
    Replies: 9
    Last Post: 1 Feb 2012, 11:45 PM
  2. Custom Event
    By medtrac64 in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 4 Apr 2010, 7:29 AM
  3. Custom event problem
    By mqqla in forum Ext 2.x: Help & Discussion
    Replies: 9
    Last Post: 2 May 2008, 6:39 AM
  4. Events and Custom Event Handling
    By w011117 in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 12 Feb 2008, 4:38 PM
  5. Custom event doesn't work
    By gacek999 in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 7 Oct 2007, 8:45 AM

Posting Permissions

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