$upload_button = $('#choose-files') $upload_form = $upload_button.closest('form') $file_input = $('#presigned_upload_field').find('input[type="file"]') presigned_upload_field_url = $upload_button.attr('data-presigned-upload-field-url') $upload_button.on 'click', (e) -> $file_input.click(); upload_files = (e) -> files = e.target.files if files.length $upload_form.submit() # Reset the file input, so that it can be used again $.get presigned_upload_field_url, -> $file_input = $('#presigned_upload_field').find('input[type="file"]') bind_file_input() $progress_bar = $($upload_form).append('
Something went wrong, please check your connection and try again
") bind_file_input = -> $file_input.on 'change', upload_files bind_file_input()