PDA

View Full Version : [RESOLVED 1.1.1] onchange event does not fire with file inputType



jaanus
15 Nov 2007, 1:33 PM
with yui-adapter on Linux x64 Swiftfox 2.0.0.9 (Linux only firefox flavour)


var file_fld=new Ext.form.TextField({
fieldLabel:'some_label',
name:'some_name',
inputType:'file',
allowBlank:false});

file_fld.on('change',function(){alert(1);});

some_ext_form_obj.add(file_fld);

...does not work, while...


var file_fld=new Ext.form.TextField({
fieldLabel:'some_label',
name:'some_name',
/*inputType:'file',*/
allowBlank:false});

file_fld.on('change',function(){alert(1);});

some_ext_form_obj.add(file_fld);

...does its thing.

An undocumented feature perhaps or am I simply missing something here?
I'm pretty sure, that when defining a callback on an onchange event directly on a DOM node (file input), everything would work as intended, however I'd like to keep my code clean by using the Ext API.

Thank you.

brian.moeskau
18 Nov 2007, 11:44 PM
This issue is not platform or version specific. It is a limitation in the current Ext file input implementation. Within TextField, the blur event raised by the browser is actually handled internally and translated into a change event by Ext. For file inputs, blur does not actually occur unless the button portion of the control is blurred (not the text part). Because of that, it does not currently get handled and translated correctly by Ext.

As a workaround you should be able to hook a change handler directly into the file input's element like so:

file_fld.getEl().on('change',function(){alert('1');});

Unfortunately the file input is currently a second class citizen in Ext -- we pass the fileType through as a convenience, but that's about it. I will put this on the list to refactor in a future Ext version (hopefully with styles too).

jit
4 Feb 2008, 4:56 AM
Brian,

Just wanted to check if any progress had been made refactoring the file input? I'm particularly interested in knowing whether its possible to get the default textfield styling to be applied to them.

Thanks

Jit

brian.moeskau
4 Feb 2008, 9:28 AM
Not at this point, although it is on our list for a future release.