PDA

View Full Version : activate listener issue in card layout



ramana_l_v
28 Jun 2012, 11:03 AM
Hi,
I have a container with card layout and two components in it. By default active item is 0.
Issue I am facing is activate listener for the components inside mycomponent2 are getting called when the page is loaded where active item is set to mycomponent1.

When I set active item to 1 activate listener of mycomponent2 is getting called but the activate listeners for the components inside mycomponent2 are not getting called.

What exactly needs to be done where activate listener for the components of mycomponent2 is called only when active item is set to 1 ?

Below is the sample code



Ext.define('MyAdoc.view.MyContainer', {
extend: 'Ext.container.Container',
requires: [
'MyAdoc.view.MyComponent1',
'MyAdoc.view.MyComponent2'
],
height: 355,
width: 530,
activeItem: 0,
layout: {
type: 'card'
},
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'mycomponent1'
},
{
xtype: 'mycomponent2'
}
]
});
me.callParent(arguments);
}
});


Thanks

mitchellsimoens
6 Jul 2012, 2:17 PM
What version are you using? This code works great in 4.1.x


new Ext.container.Container({
renderTo : document.body,
width : 400,
height : 400,
layout : 'card',
activeItem : 0,
items : [
{
html : 'One',
listeners : {
activate : function () {
console.log('activate one');
}
}
},
{
html : 'Two',
listeners : {
activate : function () {
console.log('activate two');
}
}
}
]
});

Only the component that matches the index in activeItem gets the activate event fired.

ramana_l_v
9 Jul 2012, 7:26 AM
I am using 4.1.x

The problem I am facing is activate listener of the child components inside the card layout component are not getting called when the parent component is activated.

The way I fixed is when the activate listener of parent component is called I am calling the listener for child components.

Thanks

mitchellsimoens
9 Jul 2012, 9:00 AM
Yes, the child items will not have their activate event called because they aren't the ones being activated plu sit would degrade performance to have that many events being fired.