s3_direct_upload icon indicating copy to clipboard operation
s3_direct_upload copied to clipboard

Submitting before file fully uploads

Open ghost opened this issue 12 years ago • 2 comments

Anyone else find in the example app that if you submit the form before the file is fully uploaded...that the record created just completely leaves out the image?

It seems like from a user perspective, this would be pretty annoying...

Has anyone found a good workaround for this?

ghost avatar Jul 22 '13 15:07 ghost

We just disable the submit button when the upload starts and enable it again when it completes or fails.

nathany avatar Jul 25 '13 00:07 nathany

I use Ladda (http://lab.hakim.se/ladda/) to disable the submit button and add an animated spinner to confirm that something is happening. There's even an option to overlay a progress bar on the button (sounds crappy but it actually looks really nice).

Just add the ladda-button class to the submit button and instantiate it on the page with

<button type='submit' class="ladda-button" data-style="expand-left">
    Submit
</button>
<script>
  var newSpinner = Ladda.create( document.querySelector( 'button' ) );
</script>

Then bind the start and stop javascript to the s3 callbacks.

jQuery(function() {
  $("#myS3Uploader").bind('s3_uploads_start', function(e) {
    newSpinner.start();
  });
});

$(document).bind('s3_uploads_complete', function() {
  return newSpinner.stop();
});

You'll need the Ladda .js files and CSS files in your asset pipeline.

weavermedia avatar Oct 24 '13 07:10 weavermedia