How to run Dropzone processQueue() when not initiating programmatically?
Asked Answered
Q

2

19

Im trying to initiate dropzone by adding the class to the form like this :

<form class="dropzone ng-pristine ng-valid dz-clickable" id="photoDropzoneDiv" action="/panel/vehicles/3/photos" accept-charset="UTF-8" method="post">

Now dropzone works. Next I set dropzone not to auto process the queue :

Dropzone.options.photoDropzone = {
    paramName: "file", // The name that will be used to transfer the file
    maxFilesize: 5, // MB
    autoProcessQueue: false,
    parallelUploads: 500,
    acceptedFiles: '.jpg,.jpeg,.JPEG,.JPG,.png,.PNG',
    addRemoveLinks: true,
    init: function(file, done) {
        this.on("queuecomplete", function(file) {
            this.removeAllFiles();
        });
    }
};

Now when I call the processQueue like this :

photoDropzone.processQueue();

It says Uncaught TypeError: photoDropzone.processQueue is not a function. How can I fix this?

Quennie answered 11/7, 2015 at 6:17 Comment(0)
B
27
Dropzone.options.addFiles = {
    maxFileSize : 4,
    parallelUploads : 10,
    uploadMultiple: true,
        autoProcessQueue : false,
    addRemoveLinks : true,
    init: function() {
        var submitButton = document.querySelector("#act-on-upload")
        myDropzone = this;
        submitButton.addEventListener("click", function() {
            myDropzone.processQueue(); 
        });
        myDropzone.on("addedfile", function(file) {
            if (!file.type.match(/image.*/)) {
                if(file.type.match(/application.zip/)){
                    myDropzone.emit("thumbnail", file, "path/to/img");
                } else {
                    myDropzone.emit("thumbnail", file, "path/to/img");
                }
            }
        });
        myDropzone.on("complete", function(file) {
            myDropzone.removeFile(file);
        });
    },
};
Bract answered 12/10, 2015 at 18:19 Comment(0)
B
40

This worked here : )

$('#submit').click(function() {
    var myDropzone = Dropzone.forElement(".dropzone");
    myDropzone.processQueue();
});
Bascule answered 22/3, 2017 at 16:17 Comment(0)
B
27
Dropzone.options.addFiles = {
    maxFileSize : 4,
    parallelUploads : 10,
    uploadMultiple: true,
        autoProcessQueue : false,
    addRemoveLinks : true,
    init: function() {
        var submitButton = document.querySelector("#act-on-upload")
        myDropzone = this;
        submitButton.addEventListener("click", function() {
            myDropzone.processQueue(); 
        });
        myDropzone.on("addedfile", function(file) {
            if (!file.type.match(/image.*/)) {
                if(file.type.match(/application.zip/)){
                    myDropzone.emit("thumbnail", file, "path/to/img");
                } else {
                    myDropzone.emit("thumbnail", file, "path/to/img");
                }
            }
        });
        myDropzone.on("complete", function(file) {
            myDropzone.removeFile(file);
        });
    },
};
Bract answered 12/10, 2015 at 18:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.