PDA

View Full Version : Activate event fires twice - why?



Tiffany A
4 Jan 2011, 9:49 PM
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

evant
4 Jan 2011, 11:46 PM
You should probably post a short test case that demonstrates the issue, just so everyone is clear.

Tiffany A
5 Jan 2011, 9:14 AM
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.

mindstuff
5 Jan 2011, 11:41 AM
@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?


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;
}
},

JeffBurr
14 Mar 2011, 10:18 AM
I am experiencing this also. When using setActiveItem on a Carousel component, the activate listener fires twice on the target item.

8dot3
15 Jun 2011, 7:49 AM
I am experiencing this as well.

ssherriff
3 Dec 2011, 9:06 PM
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,

mbritton
22 Feb 2012, 9:51 AM
I'm having this same problem. Spooky.

gypsie
1 Mar 2012, 10:24 AM
Same problem here, anyone?

gypsie
26 Mar 2012, 1:28 PM
Same problem still here. Isn't this like major flaw? Workaround within panel is to set buffer:


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.

george4buxton
30 Apr 2014, 2:10 PM
Same issue two years later