extjs - How can I attach an react to user clicking on tabs in Ext.TabPanel -


when want react user selecting row on grid, use this:

var grid = new ext.grid.gridpanel({     region: 'center',     ... }); grid.getselectionmodel().on('rowselect', function(sm, index, rec){     changemenuiteminfoarea(menuitemapplication, 'you on row index ' + index) });    

how can attach same functionality tabs? this:

var modules_info_panel = new ext.tabpanel({     activetab: 0,     region: 'center',     defaults:{autoscroll:true},     listeners: {         'tabclick': function(tabpanel, index) {             changemenuiteminfoarea(menuitemmodules,'you clicked tab index ' + index);         }     },     items:[{             title: 'section 1',             html: 'test'         },{             title: 'section 2',             html: 'test'         },{             title: 'section 3',             html: 'test'         }] }); modules_info_panel.getselectionmodel().on('tabselect', function(sm, index, rec){     changemenuiteminfoarea(menuitemmodules, 'you on tab index ' + index) }); 

addendum

thanks @timdev, works, , here how identify tab (simply via id, couldn't tab's index row's index in grid):

var modules_info_panel = new ext.tabpanel({     activetab: 0,     region: 'center',     defaults:{autoscroll:true},     items:[{             id: 'section1',             title: 'section 1',             html: 'test'         },{             id: 'section2',             title: 'section 2',             html: 'test'         },{             id: 'section3',             title: 'section 3',             html: 'test'         }] });  modules_info_panel.items.each(function(tab){     tab.on('activate',function(panel){         changemenuiteminfoarea(menuitemmodules, 'you opened "' + panel.id + '" tab');     }); });  replacecomponentcontent(regioncontent, modules_info_panel);  hidecomponent(regionhelp); 

you're close.

the individual panels inside tabpanel fire activate event when activated.

you attach handler each item in tabpanel @ configuration time, via listeners configuration key .

or iterate on tabs attaching listener go, like:

modules_info_panel.items.each(function(tab){     tab.on('activate',function(panel){ ... }); } 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -