Reputation: 3430
There is a unknown problem while programmatically deleting programmatically added files to Dropzone. Here is my code that is not working:
// constructor - OK
docsDropzone = new Dropzone( "#docsUpload", {
url: uploadUrl,
addRemoveLinks: true,
init: function() {
this.on( 'removedfile', removedFileCallback );
}
} );
// add file - OK
var mockFile = { name: 'test.jpg', size: 0 };
docsDropzone.emit( "addedfile", mockFile );
docsDropzone.emit( "thumbnail", mockFile, 'test.jpg' );
// remove files - NOT OK
docsDropzone.removeAllFiles( true );
Upvotes: 10
Views: 20114
Reputation: 3430
addedfile
function is not adding files to dropzone.files
so it must be added manually:
// add file - OK
var mockFile = { name: 'test.jpg', size: 0, status: 'success' };
docsDropzone.emit( "addedfile", mockFile );
docsDropzone.emit( "thumbnail", mockFile, 'test.jpg' );
docsDropzone.files.push( mockFile ); // file must be added manually
// remove files - NOW OK
docsDropzone.removeAllFiles( true );
Upvotes: 26