backbone-upload-manager icon indicating copy to clipboard operation
backbone-upload-manager copied to clipboard

Clicking cancel uploads only removes half of files from queue

Open paradigmbase opened this issue 11 years ago • 6 comments

In my app as well as the demo page, clicking on Cancel Uploads only removes half of the files in the queue.

paradigmbase avatar Jan 29 '14 19:01 paradigmbase

For the cancel all handler, a while loop works better then using each.

backbone.upload-manager.js ln 198:

// Add cancel all handler
$('button#cancel-uploads-button', this.el).click(function(){
    while (self.files.length) {
        self.files.at(0).cancel();
    }
});

paradigmbase avatar Jan 29 '14 20:01 paradigmbase

@paradigmbase Nice solution. Thx a lot!

Darksoulsong avatar Feb 07 '14 12:02 Darksoulsong

Np

paradigmbase avatar Feb 12 '14 18:02 paradigmbase

Doesn't look like this solution ever got merged in. The bug persists on the demo page. I will setup a PR for this.

dogeared avatar Aug 08 '14 14:08 dogeared

@paradigmbase Your code snippet seams to always loop on the first item, as the cancel method on file don't remove it from files collection... Right ?

sroze avatar Aug 08 '14 14:08 sroze

It essentially does the same thing as your original code, except that instead of using each it uses a while loop. The each loop didn't allow the cancel method to be called on each model in the collection, but a while loop does.

It does call cancel on the first item of the collection. However, each time the loop iterates this is a new item since the previous first item has been removed.

paradigmbase avatar Aug 08 '14 15:08 paradigmbase