选项卡面板侦听器不起作用

时间:2013-09-17 05:50:50

标签: extjs sencha-touch-2 tabpanel

在单击时尝试在选项卡面板中调用函数方法时,方法在侦听器中调用。这是我的代码,

var homepnl=Ext.create('Ext.TabPanel', {
    id:'homepnl',
    width:'100%',
    height:'100%',
    tabBarPosition: 'bottom',

    defaults: {
        styleHtmlContent: true
    },
    items: [
        {
            title: 'My Items',
            iconCls: 'star',
            id:'divtab1',
            items: [myitemspnl]
        },
        {
            title: 'Add Items',
            iconCls: 'compose',
            id:'divtab2',
            items: [additemspnl]
        },
        {
            title: 'Friend List',
            iconCls: 'team',
            //id:'friendsid',
            id:'divtab3',
            items:[friendslistpnl],
        },
        {
            title: 'Search',
            iconCls: 'search',
            items: [searchpnl]
        },
        {
            title: 'Settings',
            iconCls: 'settings',
            items: [settingspnl]
        }
    ],
        listeners: {
            tabchange: function (homepnl, tab) {
                alert(homepnl.id);// No alert is coming here
            }
        }
    });

我的代码在这里有什么问题?请帮我解决

1 个答案:

答案 0 :(得分:0)

我正在查看Sencha touch文档,没有事件tabchange。请参阅documentation

您可以使用activeitemchange活动。

在侦听器中使用以下代码:

listeners: {
    activeitemchange: function (homepnl, value, oldValue) {
        alert(homepnl.id);
    }
}