Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hooks for upload complete #210

Open
JulieGoldberg opened this issue Jul 30, 2020 · 0 comments
Open

Hooks for upload complete #210

JulieGoldberg opened this issue Jul 30, 2020 · 0 comments

Comments

@JulieGoldberg
Copy link

Is it possible to add a hook I can use when the upload is complete? I want to auto-submit the form as soon as it's done.

I can't add a change event to the file-url being set, since it's a hidden. So I've implemented a simple work-around -- checking if the url has a value, and trying every second once the file-input has been set. I did it simply with timeouts, though I'm sure I could have done it more elegantly with promises.

`
var maxChecksForUploadComplete = 360;
var submitFormOnceS3UploadIsComplete = function() {
if ($('.file-url').val()) {
return uploader.submitForm();
}
else if (maxChecksForUploadComplete) {
maxChecksForUploadComplete--;
return setTimeout(submitFormOnceS3UploadIsComplete, 1000)
}
else { //too many tries, exit the recursive loop
return;
}
}

$('.file-input').change(submitFormOnceS3UploadIsComplete);
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant