How do I wait for multiple jquery file uploads?
<p>I'm trying to refresh the page after multiple files have been uploaded using <a href="http://blueimp.github.com/jQuery-File-Upload/" rel="nofollow">jquery file upload</a>:</p>

<p>For some reason my test message is being called after each individual file upload completion and I'm trying to call this just once after all the files have uploaded. Is this possible?</p>

<p>HTML:</p>

<pre><code>&lt;form id="fileupload" action="server/php/" method="POST" enctype="multipart/form-data"&gt;
    &lt;!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload --&gt;
    &lt;div class="row fileupload-buttonbar"&gt;
        &lt;div class="span7"&gt;
            &lt;!-- The fileinput-button span is used to style the file input field as button --&gt;
            &lt;span class="btn btn-success fileinput-button"&gt;
                &lt;i class="icon-plus icon-white"&gt;&lt;/i&gt;
                &lt;span&gt;Add files...&lt;/span&gt;
                &lt;input type="file" name="files[]" multiple&gt;
            &lt;/span&gt;
            &lt;button type="submit" class="btn btn-primary start"&gt;
                &lt;i class="icon-upload icon-white"&gt;&lt;/i&gt;
                &lt;span&gt;Start upload&lt;/span&gt;
            &lt;/button&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;!-- The loading indicator is shown during file processing --&gt;
    &lt;div class="fileupload-loading"&gt;&lt;/div&gt;
    &lt;br&gt;
    &lt;!-- The table listing the files available for upload/download --&gt;
    &lt;table role="presentation" class="table table-striped"&gt;&lt;tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;/form&gt;
</code></pre>

<p>JQuery</p>

<pre><code>$('#fileupload').bind('fileuploadcompleted', function (e, data) {
    e.preventDefault();

    // I would expect to see this after all files ahve uplaoded but I see it for each file upload ?
    alert("Completed");

    //location.reload();
    ...
})
</code></pre>
