aaltowebapps / faq

Frequently Asked Questions
9 stars 0 forks source link

File upload #10

Open ghost opened 12 years ago

ghost commented 12 years ago

All the course examples using "file" input element of HTML forms are based on jQuery .live('change') handler. For our team assignment, there might be a need to upload the same file many times, with different conversion option. The 'change' event doesn't happen. How to do it in 'mobile' manner?

It is possible to make the "file" input visible and separate file selecting from upload - thus we would have needed functionality but...

vugi commented 12 years ago

There are several options:

1) You could just trigger the change event manually: $("#elem").trigger('change');

2) Better option is to separate the change-event callback function as a separate function. Then the function can be easily called again when needed.

ghost commented 12 years ago

Yes, that's true about making it a separate function. This also makes code more readable.

As for triggering event manually (in exact meaning of the word), that means adding another button which I'd like to avoid.

Yes, the handler can be triggered from another code - the question is when?

Is there any way to get a notification when a file selector dialog has been successfully closed (and not cancelled)? I tried 'blur' but it gets triggered before the file is selected.