0

我对下一个代码块有疑问:

run: function(e, row){
    var me = this;

    var container = Ext.getCmp('centercontainer');

    try {
        container.removeAll();
    } catch(e) {  }

    // This block is called from another file, I just put it here to show you.
    me.panels = [{
        xtype: 'tabpanel',
        id: 'containertabpanel',
        items: [{
            itemId: 'package',
            title: me.PackageTitle
        },{
            itemId: 'excursion',
            title: me.ExcursionTitle
        }]
    }];

    // Reset
    container.setTitle(me.EditDestinationTitle + row.data.name);
    container.add(me.panels);
    me.tabs = container.getComponent('containertabpanel');

    // console.log(Ext.ComponentQuery.query('#containertabpanel > #package'))

    me.control({
        // Work with 
        // 'tab': {

        // Doesn't work
        'containertabpanel > package': {
            mouseover: me.doPackage
        }
    })

},

任何人都知道如何捕捉标签面板组件的“包”项的点击事件?我看到当我在 this.control 查询上只使用“选项卡”选择器时,它可以工作,但我不能只获得“包”选项卡组件。

先感谢您。

4

3 回答 3

0

在您的选项卡面板的定义中,您可以指定 -

listeners:{
    click:{
        fn: function(){
           //click handling code goes here
        }
    }
}
于 2012-02-09T22:27:21.997 回答
0

如果我理解正确,这是控制器代码,并且您正试图在面板上捕获一个项目,该面板是选项卡面板中的众多项目之一

您可以做的是通过组件查询语法通过任何独特的属性来识别您的面板,如下所示: button[myprop=blah]
此语法将匹配页面上具有以下配置的任何按钮:

{
    xtype:'button' 
    myprop:'blah'
}

在您的情况下,您可以尝试tab[itemId=package]

您还需要注意的是控制器只能侦听由组件触发的事件。确保您正在监听的事件被触发(查看文档)。如有必要,您始终可以触发自定义事件。

于 2012-02-10T06:06:15.177 回答
0

你需要这样做

me.control({
    // Work with 
    // 'tab': {

    // Doesn't work
    'containertabpanel > #package': {
        mouseover: me.doPackage
    }
})
于 2016-03-01T14:06:36.707 回答