PDA

View Full Version : FileUploadField: how to upload files after ‘fileselected’ ?



grigory666
18 Jan 2010, 5:54 AM
I try to load file immediately after ‘fileselected’.


var fbutton = new Ext.ux.form.FileUploadField
({
buttonOnly : true,
listeners :
{
'fileselected': function(fb, v)
{
fbutton.getForm().submit
({
url : '/rm/load.php',
waitMsg : 'Loading...',
params : params
});
}
}
});



But there is error:
fbutton.getForm is not a function

How to do submit in Ext.ux.form.FileUploadField ?

flanders
18 Jan 2010, 6:19 AM
You're trying to execute a function wich doesn't exist. The fbutton is a reference to a FileUploadField, the methode getForm() you're looking for belongs to FormPanel. You should grab a reference to the form in the handler.

You should check the docs for the scope option when declaring a handler, set it to the form and change fbutton.getForm() to this.getForm().

grigory666
18 Jan 2010, 6:56 AM
but in FormPanel I can't set loading on 'fileselected'.

How to do it ?

flanders
18 Jan 2010, 8:33 AM
Why don't u try this?


var fbutton = new Ext.ux.form.FileUploadField
({
buttonOnly : true,
listeners :
{
'fileselected': {
fn: function(fb, v)
{
this.getForm().submit
({
url : '/rm/load.php',
waitMsg : 'Loading...',
params : params
});
},
scope: YourFormPanel
}


}
});or


fbutton.on('selectfile', function() {
this.getForm().submit({
..
});
}, yourFormPanel);Either should work

And you should read up on scoping issues. See the documentation on the on() function or listeners config

grigory666
9 Feb 2010, 12:00 AM
Thank you flanders,
but Ext.ux.form.FileUploadField doesn't work with Opera:
loading (progressbar) doesn't stop :(

Does anybody knows, how to fix that?