0

我尝试按照http://www.sencha.com/forum/showthread.php?234909-tab-panel-doesn-t-switch-between-tabs-的建议将 this.callParent(arguments) 添加到选项卡面板的初始化事件中动态添加时,但我得到:

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(格林威治标准时间 - 4:00)

通过搜索网络,我现在相信因为我重写了初始化,所以我需要调用超类的初始化方法,以便它的代码也将被执行。正如 user1479606 所指出的那样,调用 this.callParent 将永远不会起作用。所以,问题就变成了:如何调用超类的初始化方法?

4

1 回答 1

0

我认为您的应用程序不适用于您的情况,因为您应该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(){                       
            }
        }
        ]
    });
}

希望能帮助到你 :)

于 2012-12-30T05:18:26.587 回答