I have too much dificulty on access extjs objects. This time I have a viewport with two items, a toolbar on the north and a tab panel on center region. I don't know how do I can access the tabpanel object to user his methods or whatever I want. This is my code:
Ext.onReady(function()
{
var tabs = Ext.getCmp('dynamic-tabs');
var viewport = new Ext.Viewport(
{
layout: 'border',
renderTo: document.body,
items: [
{
region: 'north',
height: 25,
xtype: 'toolbar',
items: [
{
xtype: 'button', text: 'Início', iconCls: 'home',
handler:function() {
tabs.add({
title: 'Início',
html: 'Tab Body',
closable:true
}).show();
}
},
{
xtype: 'button', text: 'Sistema', iconCls: 'sistema',
menu: {
items: [
{
text: 'Usuários',
iconCls: 'usuario',
handler: function(){
tabs.add({
title: 'Usuários',
html: 'Tab Body',
closable:true,
autoLoad: 'form.php'
}).show();
}
},
{
text: 'Configurações',
iconCls: 'sistema',
handler: function(){
tabs.add({
title: 'Configurações',
html: 'Tab Body',
closable:true,
autoLoad: 'form.php'
}).show();
}
},'-',
{
text: 'Sair',
iconCls: 'logoff',
handler: function(){
tabs.add({
title: 'Sair',
html: 'Tab Body',
closable:true,
autoLoad: 'form.php'
}).show();
}
}
]
}
}
]
}
,
{
region: 'center',
xtype: 'tabpanel',
id: 'dynamic-tabs',
items: [
{title: 'Início', autoLoad: 'iframe.php?url=form.php', active:true}
]
}]
});
tabs.setActiveTab(0); // Throws: tabs is undefined
});
For exemple, I want to uset setActiveTab() in any place of my code. It's basic but I realy don't know =S
Edit: I changed the code setting the var tabs once on the top. Even if I put this tabs.setActiveTab(0); on any handler of any button, it's throws the same error.
Note that Ext version is 3.4!!
var tabs = Ext.getCmp('dynamic-tabs'); tabs.callAnyMethod();- deviousdodotabs1and then calledtabs1.setActiveTab(0)but it throwstabs1 is not defined- user898741tabs.setActiveTab(0);at the end of any handler and it should work. - deviousdodoExt.onReady(function() { var tabs = Ext.getCmp('dynamic-tabs'); var viewport = new Ext.Viewport( { // Supressed code }); tabs.setActiveTab(0); });But shows me the same error. - user898741