As upload widget does not support modifying files collection after widget's instantiation, I have to destroy and recreate upload widget when I need to modify files.
I noticed that after widget has been destroyed/recreted removing a file fires several HTTP requests to removeUrl, however remove event handler is fired just once. This doesn't happen to upload action.
In my opinion it's a Kendo UI issue, do you agree?
The following is my code (simplified):
var uploaderOptions = { enabled: true, files: myCollection, async: { saveUrl: myUrl1, removeUrl: myUrl2, autoUpload: true }, upload: function (e) { /* code here */ }, remove: function (e) { /* code here */ }, success: function (e) { /* code here */ }, complete: function (e) { /* code here */ }};// When we need to modify files collection:
// Hack that helps avoid multiple requests: uploadWidget._submitRemove = function () { };
uploadWidget.clearAllFiles();uploadWidget.destroy();uploaderOptions.files = updatedCollection;uploadWidget = $("#" + attachmentWidgetId).kendoUpload(uploaderOptions).data("kendoUpload");