Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EXTJS OnClick Tab Event

Tags:

tabs

extjs

Is there a way to attach an OnClick event to a tab switch in EXTJS?

I make the grid like this:

var simple = new Ext.FormPanel({
    labelWidth: '100%',
    border:false,
    width: '100%',
            style: 
            {
                height: '291px'
            },
    items: {
        xtype: 'tabpanel',
        activeTab: 0,
        //labelWidth: 75, // label settings here cascade unless overridden
        items:[{
        url:'save-form.php',
        title: 'Tab 1',
  ...

Thanks!

like image 937
Doug Molineux Avatar asked Dec 20 '10 16:12

Doug Molineux


2 Answers

I added in a listener after the tabs were defined like this:

//define all tabs, and after the ] from the tab panel JSON: 
listeners: {
    'tabchange': function(tabPanel, tab) {
        alert("tab changed");
    }
}

This just alerts when the tab changed, which is sufficient for my purposes. I'm not sure though how to find out which tab is the current tab.

Hope this helps someone in the future.

like image 112
Doug Molineux Avatar answered Nov 07 '22 21:11

Doug Molineux


There is a tabchange event that fires when the active tab changes: http://www.sencha.com/learn/Ext_FAQ_TabPanel

like image 2
lee whitbeck Avatar answered Nov 07 '22 21:11

lee whitbeck