2

I'm using the blueimp file upload plugin, everything is working fine so far. I have implemented this plugin into my own form, which is submitted through ajax, this is working well too.

Now the problem: after successful submission, I go back to the form, all input fields are cleared, except the file upload list.

this solution should work, and it does when I use in within an onclick function:

https://github.com/blueimp/jQuery-File-Upload/issues/1631

But I don't want to use a separate clear button, I want to clear the form + file list after successful submission, so logically, I wrote this code:

 success: function(response) {
  // on success
  if (response.success === 1) {
    $('#fileupload table tbody tr.template-download').remove();

but this doesn't work, even when I just put the line on top, below document.ready (so clear onload).

Why does this only work onclick? Am I missing something? Any suggestions?

Thanks in advance for your assistance

4 Answers 4

6

Try calling this, this worked for me

$("#fileupload").find(".files").empty();
Sign up to request clarification or add additional context in comments.

Comments

1

None of the solution posted before worked for me. But unbinding the upload button did the trick.

progressall: function (e, data) {
  var progress = parseInt(data.loaded / data.total * 100, 10);
  if(progress==100)
    {  
      $('#btnUploadAll').unbind('click');
    }
}

1 Comment

This is working for me too, I guess it's because we're binding data.submit() to the click handler of the upload button, right @Ray?
0

Do you have tried to put it on the done (instead of success) :

 $('#fileupload').fileupload({
        url: url,
        dataType: 'json',
        done: function (e, data) {
                 $('#fileupload table tbody tr.template-download').remove();
            }
        });

Comments

0

just have a look at option "replaceFileInput". I had the same problem and after adding this option with value "false" to the jquery file upload plugin it works for me.

Seems that jquery file upload is a little bit tricky at this point and during replacement of the input field behind the scene, inmportant event signups will get lost.

Don't know if its a bug or a feature. :)

Regards

Udo

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.