1. #1
    Ext JS Premium Member
    Join Date
    Dec 2010
    Posts
    3
    Vote Rating
    0
    Tiffany A is on a distinguished road

      0  

    Default Activate event fires twice - why?

    Activate event fires twice - why?


    I'm listening out for the activate event, which I use to append a few items. Console logging in Safari shows me the activate event fires twice, thus appending my items twice. Why is it doing this? I'm using 1.0.2.

    Thanks

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,997
    Vote Rating
    649
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    You should probably post a short test case that demonstrates the issue, just so everyone is clear.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Ext JS Premium Member
    Join Date
    Dec 2010
    Posts
    3
    Vote Rating
    0
    Tiffany A is on a distinguished road

      0  

    Default


    I have to run in a few minutes, but very quickly, thank you for the reply.

    My application is MVC. I have an Ext.Panel with card layout (called viewport and I will refer to it as such from now on) defining the important sections of my application. These sections are all panels with other controls called within and are controlled via routes calling different controllers.

    When I set a new active item (one of my various section panels) on my viewport, I listen for the activate event and it is then that it fires twice. This occurs on multiple panels and I have determined that that even a simple panel with nothing but some HTML in it will fire the activate event twice. Hope this helps.

  4. #4
    Ext JS Premium Member
    Join Date
    Dec 2010
    Posts
    15
    Vote Rating
    0
    mindstuff is on a distinguished road

      0  

    Default


    @evant

    It looks like when the panel is layed out for the first time an event for activate is called, then also when setActiveItem is called. Is this the expected behaviour?

    Code:
    Ext.layout.CardLayout = Ext.extend(Ext.layout.FitLayout, {
        type: 'card',
    
        sizeAllCards: false,
        hideInactive: true,
    
        beforeLayout: function() {
            this.activeItem = this.getActiveItem();
            return Ext.layout.CardLayout.superclass.beforeLayout.apply(this, arguments);
        },
    
        onLayout: function() {
            Ext.layout.FitLayout.superclass.onLayout.apply(this, arguments);
    
            var activeItem = this.activeItem,
                items = this.getLayoutItems(),
                ln = items.length,
                targetBox = this.getTargetBox(),
                i,
                item;
    
            for (i = 0; i < ln; i++) {
                item = items[i];
                this.setItemBox(item, targetBox);
            }
    
            if (!this.firstActivated && activeItem) {
                if (activeItem.fireEvent('beforeactivate', activeItem) !== false) {
                    activeItem.fireEvent('activate', activeItem);
                }
                this.firstActivated = true;
            }
        },

  5. #5
    Touch Premium Member
    Join Date
    Mar 2007
    Posts
    67
    Vote Rating
    0
    JeffBurr is on a distinguished road

      0  

    Default Any resolution?

    Any resolution?


    I am experiencing this also. When using setActiveItem on a Carousel component, the activate listener fires twice on the target item.

  6. #6
    Sencha User
    Join Date
    May 2011
    Posts
    12
    Vote Rating
    0
    8dot3 is on a distinguished road

      0  

    Default


    I am experiencing this as well.

  7. #7
    Sencha User
    Join Date
    Nov 2007
    Posts
    8
    Vote Rating
    0
    ssherriff is on a distinguished road

      0  

    Default


    The last post on this seems to have been awhile ago. I'm also experiencing this, has anyone figured out why it is happening and/or how to stop it?

    Cheers,

  8. #8
    Sencha User
    Join Date
    Jan 2012
    Location
    Atlanta, Georgia
    Posts
    40
    Vote Rating
    2
    mbritton is on a distinguished road

      0  

    Default


    I'm having this same problem. Spooky.

  9. #9
    Sencha User
    Join Date
    Dec 2011
    Location
    Sacramento, California
    Posts
    75
    Vote Rating
    9
    gypsie will become famous soon enough

      0  

    Default


    Same problem here, anyone?

  10. #10
    Sencha User
    Join Date
    Dec 2011
    Location
    Sacramento, California
    Posts
    75
    Vote Rating
    9
    gypsie will become famous soon enough

      0  

    Default


    Same problem still here. Isn't this like major flaw? Workaround within panel is to set buffer:
    Code:
            this.on('activate',function(){
                alert('activated');    
            },this,{buffer:100});
    This solves the problem when running actions from panel, but in new MVC model one should set all the actions in controller and controller only. I have no idea how to set buffer on function in controller. If anyone knows how to set buffer on function in controller please let me know.

Similar Threads

  1. Card Layout Activate Event
    By parky128 in forum Ext 3.x: Help & Discussion
    Replies: 8
    Last Post: 12 Jul 2010, 10:17 AM
  2. Activate Event Firing
    By timw in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 7 Apr 2010, 1:08 PM
  3. tab activate event help
    By MoShAn480 in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 10 Sep 2008, 3:27 AM
  4. activate event
    By Silent79 in forum Ext 2.x: Help & Discussion
    Replies: 12
    Last Post: 26 Nov 2007, 3:54 PM
  5. Activate event in ContentPanel and gridPanel?
    By franklt69 in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 10 Feb 2007, 12:23 PM

Thread Participants: 8