Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.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
Sencha touch 2 在控制器中引用容器的子项_Sencha Touch 2 - Fatal编程技术网

Sencha touch 2 在控制器中引用容器的子项

Sencha touch 2 在控制器中引用容器的子项,sencha-touch-2,Sencha Touch 2,如何在Sencha Touch 2控制器中通过itemId引用容器的子项?例如,一个xtype为“mypanel”的容器,它包含一个itemId为“mybutton”的按钮。在控制器中,我想为按钮分配一个偶数处理程序。我该怎么做 我的应用程序相当大,通常有一个组件的副本,所以我在应用程序中的任何地方都不使用id,而是使用itemId Ext.define('myapp.controller.Test', { extend: 'Ext.app.Controller', confi

如何在Sencha Touch 2控制器中通过itemId引用容器的子项?例如,一个xtype为“mypanel”的容器,它包含一个itemId为“mybutton”的按钮。在控制器中,我想为按钮分配一个偶数处理程序。我该怎么做

我的应用程序相当大,通常有一个组件的副本,所以我在应用程序中的任何地方都不使用id,而是使用itemId

Ext.define('myapp.controller.Test', {
    extend: 'Ext.app.Controller',

    config: {
        control: {
            myButton: {
                tap: 'showView'
            }
        },
        refs: {
            myPanel: 'mypanel',
            myButton: '?'
        }
    },

    showView: function(){

    }
});

有关ComponentQuery的更多信息,请参见此处:

当使用itemId而不是id时,您还需要在控制器的ref中提及包含itemId元素的父元素,如下所示:

refs: {
    mybutton: 'xtype_of_panel #itemId_button'
    //where 'itemId_button' is the itemId and 'xtype_of_panel' is the parent that contains the element with the itemId of 'itemId_button'
}
refs: {
    mybutton: 'xtype_of_panel #itemId_button'
    //where 'itemId_button' is the itemId and 'xtype_of_panel' is the parent that contains the element with the itemId of 'itemId_button'
}