How to disable clickable form using Dropzone.js?

I use Dropzone.js to upload files to the server. I set my Dropzone maxFiles parameter to 10 and I have tried this:

 $('.dropzone').dropzone({ maxFiles: 10, init: function() { this.on('maxfilesreached', function() { $('.dropzone').unbind('click'); }); } }); 

... but does not work. What is a solution to remove clicks from .dropzone or in some other way so that the user cannot add more files?

+10
javascript jquery
Jun 12 '14 at 20:29
source share
5 answers

Why don't you just use CSS to disable the click event. When the maximum files are reached, Dropzone will automatically add the dz-max-files-reached class.

Use css to disable clicking on dropzone: .dz-max-files-reached { pointer-events: none; cursor: default; } .dz-max-files-reached { pointer-events: none; cursor: default; }

+23
Apr 01 '15 at 13:35 on
source share

It works EXCELLENT !!! and works with 4.0.1

 //disable the click of your clickable area $(".dz-hidden-input").prop("disabled",true); //enalbe the click of your clickable area $(".dz-hidden-input").prop("disabled",false); 
+9
Feb 18 '15 at 6:45
source share
 myDropzone.on('maxfilesreached', function() { myDropzone.removeEventListeners(); }); myDropzone.on('removedfile', function (file) { myDropzone.setupEventListeners(); }); 

Don't forget init _updateMaxFilesReachedClass if you have files from your server.

 myDropzone._updateMaxFilesReachedClass() 
+4
Apr 22 '16 at 17:30
source share

The Dropzone object has a clickable parameter field, which is true by default.

Depending on your scenario, you can set this value to false when registering a Dropzone instance, or if necessary update the value at run time.

+2
Nov 20 '14 at 18:31
source share

Here we go, updated based on the comments below.

How to disable the “click to open dialog” dropzone event when maxFiles is reached:

 $('.dropzone').dropzone({ maxFiles: 10, init: function() { this.on('maxfilesreached', function() { $('.dropzone').removeClass('dz-clickable'); // remove cursor $('.dropzone')[0].removeEventListener('click', this.listeners[1].events.click); }); } 

I don’t know how reliable "1" is in this.listeners[1] , but that the click event function lives in my current dropzone configuration.

+1
Jun 12 '14 at 21:06
source share



All Articles