PDA

View Full Version : on click on a tabpanel?



nofx
27 Sep 2011, 1:55 AM
I have a tabpanel with a few tabs, but i would like to catch the 'click' event when the 2nd tab is opened/clicked on.

So i tried to do that with 'listeners', but for some reason it isn't responding to it. I never get to see the alert message.

Is there a way to add an onclick listener to a tab in a tabpanel?



{
title: 'Test',
iconCls: 'favorites',
cls: 'card card2',
listeners: {
click: {
element: 'el',
fn: function()
{
alert('aaa'); // This isn't showing at all...
}
}
}
}

AndreaCammarata
27 Sep 2011, 2:11 AM
Ho nofx.
Take a look at this thread.

http://www.sencha.com/forum/showthread.php?120964-How-to-add-handler-to-TabPanel-s-buttons

Hope this helps.

nofx
27 Sep 2011, 2:23 AM
Thanks, that's exactly what i need, but unfortunately it isn't working for me.

This is what i've tried:



{
title: 'Test',
iconCls: 'favorites',
cls: 'card card2',
listeners: {
beforecardswitch: function(cnt, newCard, oldCard, index, animated) {
//alert('This doesnt work');
fn: function() { alert('This isnt working either..'); }
}
}
}


But both are not working for me... Any idea what the problem could be..?

AndreaCammarata
27 Sep 2011, 2:30 AM
You have to add the listener to your TabPanel, not on a card placed inside of it ;)

nofx
27 Sep 2011, 3:29 AM
You have to add the listener to your TabPanel, not on a card placed inside of it ;)

Ahh, stupid me xD

Thanks though, it's working good now! :)

AndreaCammarata
27 Sep 2011, 4:35 AM
Ahh, stupid me xD

Thanks though, it's working good now! :)

You are welcome ;)