Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/475.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ExtJS getCmp面板的id不为';不连载?_Javascript_Extjs_Sencha Touch 2 - Fatal编程技术网

Javascript ExtJS getCmp面板的id不为';不连载?

Javascript ExtJS getCmp面板的id不为';不连载?,javascript,extjs,sencha-touch-2,Javascript,Extjs,Sencha Touch 2,不幸的是,我找不到任何关于按id获取“Ext.tab.Panel”的有用信息。我将更详细地介绍来源: 我正在定义要使用的面板: 在这个面板中包含的当前活动视图中,我创建了一个按钮并在其上放置了一个处理程序: 其中“AnotherView”是视图的id,该视图也是面板的一部分。 但我在尝试“设置活动选项卡”时出错: Uncaught TypeError: Object [object Object] has no method 'setActiveTab' 看起来extjs正在查找对象

不幸的是,我找不到任何关于按id获取“Ext.tab.Panel”的有用信息。我将更详细地介绍来源:

我正在定义要使用的面板:

在这个面板中包含的当前活动视图中,我创建了一个按钮并在其上放置了一个处理程序:

其中“AnotherView”是视图的id,该视图也是面板的一部分。
但我在尝试“设置活动选项卡”时出错:

Uncaught TypeError: Object [object Object] has no method 'setActiveTab'
看起来extjs正在查找对象,但无法序列化


我只想通过自定义按钮处理程序切换视图

问题在于,选项卡面板没有功能
'setActiveTab'

您必须改用
'setActiveItem'

Sencha Touch 2 Api:


感谢您的快速和非常有益的答复。看来我在为ExtJS 4.1(而不是sencha 2.1)寻找错误的文档
xtype: 'button',
text: 'Switch View',    
handler: function () {
    var main = Ext.getCmp('mainTabPanel'); //.getActiveTab();
    main.setActiveTab(Ext.getCmp('AnotherView'));
...
Uncaught TypeError: Object [object Object] has no method 'setActiveTab'
xtype: 'button',
text: 'Switch View',    
handler: function () {
    var main = Ext.getCmp('mainTabPanel'); //.getActiveTab();
    main.setActiveItem(Ext.getCmp('AnotherView'));
    //main.setActiveItem(1); //You can also set the new item with the index of it
    ...