blueimp / jQuery-File-Upload

File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads.
https://blueimp.github.io/jQuery-File-Upload/
MIT License
30.96k stars 7.96k forks source link

Callback after bulk delete #3657

Open rnixx opened 4 years ago

rnixx commented 4 years ago

Bulk delete implementation simply looks up delete buttons of selected items in file list and triggers click on them.

https://github.com/blueimp/jQuery-File-Upload/blob/master/js/jquery.fileupload-ui.js#L638

Would be great if the delete requests get tracked and an event gets fired after bulk deletion completes.

Usecase is reloading of some parts of the page after bulk delete.

blueimp commented 4 years ago

Hi @rnixx and thanks for your suggestion.

While there is no event for bulk deletion, there are individual events for each file deletion (see UI events):

$('#fileupload')
    .on('fileuploaddestroy', function (e, data) {/* ... */})
    .on('fileuploaddestroyed', function (e, data) {/* ... */})
    .on('fileuploaddestroyfailed', function (e, data) {/* ... */})

If you want to implement a bulk deletion trigger yourself, you could do so by making use of the above events and some shared state to see if any destroy request are in progress, similar to how the start/stop callbacks in the core library are implemented: https://github.com/blueimp/jQuery-File-Upload/blob/1c84ab1ed9e7547701222484e4e770bfeaa7862e/js/jquery.fileupload.js#L1047-L1050

I'll mark this as a feature request.