Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can fix this “Dropzone already attached” error?

HTML

<div class="dz dz-clickable dz-started">
   <div id="design-image" class="dropzone"></div>
</div>

jQuery

Dropzone.autoDiscover = false;
$("div#design-image").dropzone({url:"myUrl"});

I set up Dropzone.autoDiscover = false; still not working.

like image 816
Sadikhasan Avatar asked Aug 06 '16 10:08

Sadikhasan


Video Answer


2 Answers

You have to put autoDiscover option before $(document).ready, like :

//Dropzone Configuration
Dropzone.autoDiscover = false;

$(document).ready(function(){
  // Manual dropzone init
  $("div#design-image").dropzone({url:"myUrl"});
});`
like image 139
Camille Avatar answered Oct 09 '22 20:10

Camille


You already have a reference to the dropzone by giving your html element a class of "dropzone". No need to create it via jquery. Reference it using:

var myDropzone = Dropzone.forElement("div#design-image");

And your $("div#design-image") selector is in-efficient. Ids are supposed to be unique across your whole dom tree. Use $("#design-image")

like image 43
Peter Chaula Avatar answered Oct 09 '22 19:10

Peter Chaula