PDA

View Full Version : What FileField event to use for form.submit()



arnoldvillasanta
6 Jan 2015, 11:59 PM
What event in FileField can I use to call a global controller (that holds the form.submit)?

I've tried the 'change' event but it's not working.
The log tells that the controller was called, the form.submit was triggered but the FILE is not sent in the server (as per PHP callback message).

It might be that the FileField's reference to the file is not in the form yet during 'change' event.

For the meantime, (to make it work), I made the 'change' event call a button.click() of a hidden button to submit the form.

Thanks in advance.

lumberjack
8 Jan 2015, 1:30 PM
So you're trying to submit the form when the user selects the file?

You could delay the listener.



{
xtype: 'filefield',
listeners: {
change: {
fn: function (field) {
field.up('form').submit();
},
delay: 100
}
}
}

Regards,
Brian

arnoldvillasanta
8 Jan 2015, 10:52 PM
Thanks Brian for the quick reply... it works!!!

We've tried before to use the delay... but what we did is to delay the methods inside the "change" event.

We never thought about delaying the listener itself because we thought that the 'change' event is triggered 'after' the change happened...

In that case, can I assume that the FileField 'change' event is really a 'before-change' and not 'after-change' with respect to the readiness of the FileField's text field update?

It seems that there is a good reason why Sencha created "before render" and "after render" events... other than for 'convenience' purposes.