hyang
25 Jun 2009, 1:33 PM
I have been trying to use the listeners to get my active tab for changing my page title, here is my code:
<script>
var tabs = Object ();
Ext.onReady(function(){
tabs = new Ext.TabPanel({
renderTo: 'tabs1',
width:400,
activeTab: 0,
plain:true,
defaults:{autoHeight: true},
items:[
{contentEl:'mytab1', title: 'My Tab 1' },
{contentEl:'mytab2', title: 'My Tab 2' },
],
listeners: {
tabchange: function() {
var tabs1 = Ext.getCmp('tabs1');
alert (tabs1.getItem());
if (this.getActiveTab() == 0) {
document.getElementById('myTitle').innerHTML = 'My page title 1';
}
if (this.getActiveTab() == 1) {
document.getElementById('myTitle').innerHTML = 'My page title 2';
}
}
}
});
</script>
<h1 id="myTitle"></h1>
<div id="tabs1">
<div id="mytab1" class="x-hide-display">
this is my page 1
</div>
</div>
.....
Set the alert and got the message: "tabs1 is null". Did I use the right function?
Any suggestion or help will be appreciated.
<script>
var tabs = Object ();
Ext.onReady(function(){
tabs = new Ext.TabPanel({
renderTo: 'tabs1',
width:400,
activeTab: 0,
plain:true,
defaults:{autoHeight: true},
items:[
{contentEl:'mytab1', title: 'My Tab 1' },
{contentEl:'mytab2', title: 'My Tab 2' },
],
listeners: {
tabchange: function() {
var tabs1 = Ext.getCmp('tabs1');
alert (tabs1.getItem());
if (this.getActiveTab() == 0) {
document.getElementById('myTitle').innerHTML = 'My page title 1';
}
if (this.getActiveTab() == 1) {
document.getElementById('myTitle').innerHTML = 'My page title 2';
}
}
}
});
</script>
<h1 id="myTitle"></h1>
<div id="tabs1">
<div id="mytab1" class="x-hide-display">
this is my page 1
</div>
</div>
.....
Set the alert and got the message: "tabs1 is null". Did I use the right function?
Any suggestion or help will be appreciated.