Welcome Guest Search | Active Topics | Sign In | Register

AJAXUploader auto upload via Javascript Options
Sarge
Posted: Wednesday, September 19, 2007 9:04:41 AM

Rank: Member
Groups: Member

Joined: 9/14/2007
Posts: 21
I'm playing with the idea of causing the AJAXUploader to auto start the upload process once the focus leaves the upload control.
Example. User clicks browse, selects a file to upload and hits OK, then tab to the next field or clicks on the next field (onblur) this fires a javascript event that starts the upload for that AJAXUploader control. I don't see any mention of the ability to start the upload from javascript in the documentation. Is this possible?
Thanks!
BTW, your support rocks!

David L. Sargent
Developer
Washington State University
eo_support
Posted: Wednesday, September 19, 2007 9:20:33 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

Good to hear that you like our support. Please spread the word so that more people will know what we have to offer. :)

Unfortunately our uploader does not allow you to automatically start upload out of the box. It's possible to use a custom upload button (by using LayoutTemplate) and do the following with JavaScript:

1. Set up a timer upon onload;
2. Check whether the button is enabled in the timer after a reasonable delay. The upload button is intially enabled, but is quickly disabled when the uploader initializes, it then stays as disabled when there is nothing to upload, but is enabled again as soon as you select a file;
3. Call the button's onclick handler when you see the button is enabled. Make sure you do not switch this pointer when you call the handler. For example, this is correct:

Code: JavaScript
button.onclick();


And this is wrong:
Code: JavaScript
var handler = button.onclick;
handler();


In the second case this pointer is switched from the button to the window.

Obviously this would cause disastrous consequences if your uploader has multi rows --- in fact that's one of the reason that we do not offer it out of the box. Besides I am not sure whether user is used to automatic upload since the standard file upload element works otherwise. So try it with your own risk. :)

Thanks
Sarge
Posted: Wednesday, September 19, 2007 9:25:14 AM

Rank: Member
Groups: Member

Joined: 9/14/2007
Posts: 21
OK, I'll give that a try.
Yes I thought of that too, the first time I saw GMail do this I was like "What the?" Then I got used to it and thought it was quite cool.
Thanks for the helps guys!

David L. Sargent
Developer
Washington State University


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.