简体   繁体   中英

In ExtJS, event fired before clicking opening a file upload field

I have Ext.form.field.File , with the buttonOnly attribute set to true . My question is, is there any event I can execute after I press the 'browse' button but before the file selector pops-up. I want the selector not to pop-up in certain conditions that I want to check. Any advice? I tried show and keydown . Both of which didn't execute.

Yes, it is a little tricky but is what you are looking for:

var file =Ext.create('Ext.form.field.File', {
        name: 'photo',
        fieldLabel: 'Photo',
        labelWidth: 50,
        msgTarget: 'side',
        allowBlank: false,
        anchor: '100%',
        buttonText: 'Select Photo...',
        renderTo:Ext.getBody(),
});

file.mon(file.triggerWrap, {
    click : function(){ 
        alert('yes you can'); 
        file.disable();
        Ext.defer(function(){file.enable();}, 10);        
    }
});​

disable() method is used to prevent raising other events (which will prevent open the popup for selecting the file)

Here you have the working example: http://jsfiddle.net/lontivero/GmAUt/2/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM