dropzone.js and jquery version compatibility

2019-06-21 08:36发布

问题:

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.

回答1:

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();
        }
    });

});


回答2:

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



回答3:

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

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

or

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

beacuse dropzone initiate befor jquery load methodes