blueimp jquery-file-upload | Multiple instances and one global Upload-Button

768 views
Skip to first unread message

FunkeMT

unread,
Feb 19, 2014, 10:59:02 AM2/19/14
to jquery-f...@googlegroups.com
I'm using the bluimp jQuery-File-Upload-plugin (UI) to upload files in multiple instances.

I use one button which starts the upload process for every instance. 
Furthermore i have a global process statistic which summarized the stats from each instance.

    statsData = new Array(); // for global progress-bar/-stats
    $
('.fileupload').each(function () {
        statsData
.push($(this).fileupload({
        dropZone
: $(this).closest('.dropzone'),
        url
: 'foo/bar'
       
}).bind('fileuploadadd', function (e, data) {
            $
("#btn-submit-all").on('click', function () {
                $
('.fileupload-progress.global.fade').show();
                data
.submit();
       
});
       
}).bind('fileuploadstart', function (e) {
            $
('.fileupload-progress.panel.fade', $(this)).show();
       
}).bind('fileuploadprogress', function (e, data) {
           
var progress = parseInt(data.loaded / data.total * 100, 10);
            $
('.progress-bar', data.context).attr('value', progress);
       
}).bind('fileuploadprogressall', function (e, data) {
           
var progressall = parseInt(data.loaded / data.total * 100, 10);
            $
('.fileupload-progress.panel .progress-bar', $(this)).attr('value', progressall);
            renderGlobalProgress
(statsData);
       
}).fileupload('progress'));
   
});

So far, so good. 
The upload and the global progress-bar/-stats works fine.

The problem is now, when a file is `canceled` from the filelist, the file will be deleted from the list (upload template) but it is still in the "upload queue" (`filelist`?) and will upload.

I isolate the problem (probably?) to this part:

    // ...
   
}).bind('fileuploadadd', function (e, data) {
        $
("#btn-submit-all").on('click', function () {
            $
('.fileupload-progress.global.fade').show();
            data
.submit();
   
});
   
// ...

Because when i use the standard `Start Upload`-Button for each instance, everything works fine. 
But how can i use the global button to start the uploads instead of my resolution?
Reply all
Reply to author
Forward
0 new messages