Sencha touch 当某些内容动态添加到选项卡栏时,选项卡面板行为会中断
我尝试将此.callParent(参数)添加到选项卡面板的初始化事件中 正如作者所建议的,但我得到:Sencha touch 当某些内容动态添加到选项卡栏时,选项卡面板行为会中断,sencha-touch,sencha-touch-2,Sencha Touch,Sencha Touch 2,我尝试将此.callParent(参数)添加到选项卡面板的初始化事件中 正如作者所建议的,但我得到: Uncaught Error: this.callParent() was called but there's no such method (doFire) found in the parent class (Ext.Base). 有人能给我指出正确的方向吗 多谢各位 我的控制器如下: Ext.define('MyApp.controller.MyController', { e
Uncaught Error: this.callParent() was called but there's no such method (doFire) found in the parent class (Ext.Base).
有人能给我指出正确的方向吗
多谢各位
我的控制器如下:
Ext.define('MyApp.controller.MyController', {
extend: 'Ext.app.Controller',
config: {
refs: {
mytabpanel: '#mytabpanel'
}
},
init: function(application) {
this.control({
mytabpanel: {
initialize: function(component, options){
var bar = component.getTabBar();
bar.insert(0, { flex:1, xtype:'toolbar', title: '' });
bar.insert(bar.getItems().length,
{
xtype: 'toolbar',
flex: 1,
title: '',
items: [
{
xtype : 'button',
docked: 'right',
ui: 'round',
iconCls: 'info',
iconMask: true,
handler: function(){
}
}
]
});
this.callParent(arguments);
}
}
});
}
});
我的看法如下:
Ext.define('MyApp.view.MyTabPanel', {
extend: 'Ext.tab.Panel',
config: {
id: 'mytabpanel',
items: [
{
xtype: 'container',
title: 'Tab 1',
iconCls: 'info',
html: 'tab 1'
},
{
xtype: 'container',
title: 'Tab 2',
iconCls: 'info',
html: 'tab 2'
},
{
xtype: 'container',
title: 'Tab 3',
iconCls: 'info',
html: 'tab 3'
}
],
tabBar: {
docked: 'bottom'
}
}
});
编辑12月30日星期日上午6:57(GMT-4:00)
通过搜索web,我现在相信,因为我覆盖了initialize,所以我需要调用超类的initialize方法,这样它的代码也会被执行。正如用户1479606所指出的,调用this.callParent将永远无法工作。因此,问题变成了:如何调用超类的initialize方法?我认为您的应用程序在您的情况下无法工作,因为您应该使用
this.callParent(arguments)
在您的视图中,而不是您的控制器,否则您的父类将始终是Ext.Base
为了更容易理解和更好的方法,为什么不遵循Sencha Touch 2惯例,如下所示:
config: {
refs: {
mytabpanel: '#mytabpanel'
}
control: {
mytabpanel: {
initialize: 'domytabpanel'
}
}
},
domytabpanel: function(component, options) {
var bar = component.getTabBar();
bar.insert(0, {
flex:1,
xtype:'toolbar',
title: ''
});
bar.insert(bar.getItems().length,
{
xtype: 'toolbar',
flex: 1,
title: '',
items: [
{
xtype : 'button',
docked: 'right',
ui: 'round',
iconCls: 'info',
iconMask: true,
handler: function(){
}
}
]
});
}
希望有帮助:)谢谢你的回答。我尝试了你的方法,虽然它更容易理解,但在动态添加按钮和工具栏后,它也显示了选项卡栏损坏的问题。当我在插入后单击选项卡时,会得到“UncaughtTypeError:Object[Object Object]没有方法'setActive'”,并且选项卡栏中所有三个选项卡的行为都被破坏。这就是我通过调用callParent来解决的问题。将插入索引更改为3,因为您的选项卡栏已经有3项
bar。插入(3,{…})