I'm using dropzone js and it's working great on pages that I require a dropzone. On any other page though it's giving me a "Invalid dropzone element"
error message and causing issues with my other javascript.
I have a custom JS file (which loads immediately after the dropzone.js file) and at the very top of the file I have the following line of code:
Dropzone.autoDiscover = false;
This should stop it from looking at any page where I'm not enabling it programatically. The error only goes away on pages where there is a valid dropzone.
I also set the following code on line 1470 on dropzone.js to try and enable it there too:
Dropzone.autoDiscover = false;
How can I get rid of this error?
Uncaught Error: No URL provided. Uncaught Error: No URL provided happens when a Dropzone gets attached to an object without an action attribute on a form or a JavaScript configuration for specific Dropzone. This problem is caused if a Dropzone is attached to an element before configuring it via JavaScript.
Use the tag dropzonejs and there'll be plenty of people helping you out. Dropzone is a robust library trusted by millions. It started in 2012 with compatibility in mind. Whether your users use an outdated browser, or have JavaScript enabled, Dropzone got you covered.
All the documentation about Dropzone, and the multiple ways to configure and customise it, can be found on GitBook. If you need help, there are GitHub Discussions and Stackoverflow. Use the tag dropzonejs and there'll be plenty of people helping you out. Dropzone is a robust library trusted by millions.
You can check if the element is there, before you init dropzone. With jQuery you can try something like this: if ($ ('#dropzoneDiv').length) { initDropZoneHere } @Philip Where would I put this code? Do you use jQuery or pure JS? The idea is that you can check if the div exists before you init Dropzone.
With pure JS you can try this:
if (document.getElementById('DropzoneElementId')) {
var myDropzone = new Dropzone("div#DropzoneElementId", { url: "/file/post"});
// other code here
}
or if you use jQuery:
if ($('#DropzoneElementId').length) {
$("div#DropzoneElementId").dropzone({ url: "/file/post" });
// other code here
}
Long time ago but: Put the script after your Form Element and the error is gone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With