dropzone.js and jquery version compatibility
Asked Answered
V

3

5

I've been using dropzone.js in some projects recently and configuring options without no problem, but in a new project I was using a recent version of jQuery (3.1.0) auto-installed by Zend Framework 3 and it appears to cause some kind of conflict with dropzone.js version 4.3.0.

I was not able to configure options for my dropzone, it is always using default options.

Vann answered 6/10, 2016 at 7:42 Comment(3)
You need to send that error. It works great with latest version. need to know whats causing the issue?Psychologism
The problem is that there is no errors, even in the console. It is just that options are always set to default. I bypass the rest of the scripts and css files and leave only jquery and dropzone, but the result is the same. If you know any way to get errors, please tell me and I'll do my best. ThanksVann
Deeptechtons, thanks for the correction :-)Vann
W
6

If anyone else needs to use Dropzone with jQuery 3, particularly if you need to reference jQuery methods within Dropzone's callbacks, here's what worked for me:

// Do this outside of jQuery
Dropzone.autoDiscover = false;

// Start jQuery stuff
$(function() {

    // Call Dropzone manually
    $("#dropzone").dropzone({
        paramName: "image",
        maxFilesize: 8, // MB
        queuecomplete: function() {
            // Some more jQuery stuff inside Dropzone's callback
            $("#some_id").somejQueryMethod();
        }
    });

});
Whelm answered 2/7, 2017 at 11:6 Comment(2)
In a new project with jQuery 3 and Laravel 5 this solution works like a charm because, as MrCarrot said, allow to use jQuery within Dropzone's callbacks. Thanks!Vann
This answer rules! I was in the same boat with a previous configuration that worked fine with jQuery 2.2. This was the solution after moving to jQuery 3.xTremolite
T
1

Afer half hour searching i found problem it works if declare befor

$(document).ready(function () {});

or

$(function () {...});

beacuse dropzone initiate befor jquery load methodes

Terrapin answered 9/1, 2017 at 5:38 Comment(0)
V
0

My solution, of course have been to come back to an older version of jQuery, which is enough for me (1.11.1).

Hope this helps, and if anyone knows the reason of the conflict, cool!

Regards

Vann answered 6/10, 2016 at 7:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.