Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/413.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.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
Javascript 如何在ExtJS中动态触发文件输入字段单击?_Javascript_Extjs - Fatal编程技术网

Javascript 如何在ExtJS中动态触发文件输入字段单击?

Javascript 如何在ExtJS中动态触发文件输入字段单击?,javascript,extjs,Javascript,Extjs,我在dataview中有一个按钮,点击该按钮我必须打开fileUpload browse。我已经尝试了下面的代码,它似乎在ExtJSModernSDK中运行良好,但在经典el元素中为空 Ext.application({ name: 'Fiddle', launch: function () { var panel = Ext.Viewport.add({ xtype: 'panel', title: 'FileInput Field Trigger',

我在dataview中有一个按钮,点击该按钮我必须打开fileUpload browse。我已经尝试了下面的代码,它似乎在ExtJSModernSDK中运行良好,但在经典el元素中为空

Ext.application({
name: 'Fiddle',

launch: function () {
    var panel = Ext.Viewport.add({
        xtype: 'panel',
        title: 'FileInput Field Trigger',
        itemId: 'Mypanel',
        items: [{
            xtype: 'button',
            text: 'Upload file',
            listeners: {
                tap: function (button) {
                    // Find the fileinput field
                    var panel = button.up('#Mypanel');
                    var fileinput = panel.down('#myFileInputField');

                    // Programmatically click the file input field
                    fileinput.el.query('input[type=file]')[0].click();
                }
            }
        }, {
            xtype: 'formpanel',
            hidden: true,
            items: [{
                xtype: 'filefield',
                itemId: 'myFileInputField',
                listeners: {
                    change: function (field, newValue, oldValue, eOpts) {
                        Ext.Msg.alert('Results', newValue);
                    }
                }
            }]
        }]
    });
}
});

是否有任何方法可以触发此事件或任何其他方法。

如果您将上述代码完全放在经典sdk中,那么与现代sdk相比,有一些东西略有不同:

Classic中的表单xtype只是
'form'
,而不是
'formpanel'

在Classic中,按钮没有
点击
事件,只有单击按钮时执行的
处理程序

items: [{
        xtype: 'button',
        text: 'My Button',
        handler: function(button) {
            console.log('you clicked the button ', button);
        }
}]

签出工作状态

classic sdk上正在触发tap事件?classic中没有其单击事件