简体   繁体   中英

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.

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"});
});`

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")

in your dropzone.js changes:

  Dropzone.autoDiscover = true;

to:

  Dropzone.autoDiscover = false;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM