PDA

View Full Version : Beforetabchange is not working



adsl1982
27 Apr 2010, 4:42 AM
i want to add a function befor tab change,but the code is not working:

/*!
* Ext JS Library 3.2.0
* Copyright(c) 2006-2010 Ext JS, Inc.
* licensing@extjs.com
* http://www.extjs.com/license
*/
Ext.onReady(function(){
// basic tabs 1, built from existing content
var tabs = new Ext.TabPanel({
renderTo: 'tabs1',
width:450,
activeTab: 0,
frame:true,
defaults:{autoHeight: true},
items:[
{contentEl:'script', title: 'Short Text'},
{contentEl:'markup', title: 'Long Text'}
]
});
// second tabs built from JS
var tabs2 = new Ext.TabPanel({
renderTo: document.body,
activeTab: 0,
width:600,
height:250,
plain:true,
defaults:{autoScroll: true},
items:[{
title: 'Normal Tab',
html: "My content was added during construction."
},{
title: 'Ajax Tab 1',
autoLoad:'ajax1.htm'
},{
title: 'Ajax Tab 2',
autoLoad: {url: 'ajax2.htm', params: 'foo=bar&wtf=1'}
},{
title: 'Event Tab',
listeners: {activate: handleActivate, beforetabchange: tabChange},
html: "I am tab 4's content. I also have an event listener attached."
},{
title: 'Disabled Tab',
disabled:true,
html: "Can't see me cause I'm disabled"
}
]
});
function handleActivate(tab){
alert(tab.title + ' was activated.');
}
function tabChange(tab){
alert("OK");
return false;
}
});

After reading code i found that if making a change here the code will be ok:

setActiveTab : function(item){
item = this.getComponent(item);
if(this.fireEvent('beforetabchange', this, item, this.activeTab) === false){
return;
}

change to

setActiveTab : function(item){
item = this.getComponent(item);
if(item .fireEvent('beforetabchange', this, item, this.activeTab) === false){
return;
}

i wonder if here is a bug or i have got wrong using in tabpanel.

thanks.

CrazyEnigma
27 Apr 2010, 11:44 AM
If you are not getting are response sooner than you expect, there is a reason. -- Try to read the sticky on how to properly post.
Encapsulating your code in CODE tags will help.