Solved: Dropzone is already attached
- Article
- Comment
Dropzone autoDiscover false not working and Dropzone already attached error comes when you are working with dropzone. You need to understand the fact of already your dropzone is hooked. We need to destory it before load the new one.
Let’s make use of the below code to destroy the already created Dropzones and create a fresh one again. Before that lets write a function to handle this.
function DesctroyDropzones() {
$('.dropzone').each(function () {
let dropzoneControl = $(this)[0].dropzone;
if (dropzoneControl) {
dropzoneControl.destroy();
}
});
}
And You need to call this function before initiate the next Dropzone. The Code will be like this
var uploader = document.querySelector("#DocumentUpload"); Dropzone.autoDiscover = false; DestroyDropzones(); var newDropzone = new Dropzone(uploader, dropzoneOptions);
The above one will help you to solve the problem