Disabling clickable does not work
Hi! I'm trying to disable the clickable feature once the max files has been reached - but this does not work. What am I missing? Thanks.
init: function () {
var _this = this;
_this.on("addedfile", function (file) {
console.log("added file: " + file.src + " " + file.name + " " + file.status);
//disable click if at limit
if ($.isNumeric(maxFiles) && this.files.length >= maxFiles) {
console.log("max files reached");
_this.options.clickable = false;
} else {
_this.options.clickable = true;
}
Yep... that won't work because simply setting the option clickable to false will not remove the event listeners, nor the hidden file input field that handles the click.
Mh... at the moment, I think there is no clean way of removing the clickable option. Will look into it.
It is indeed a must-have requirement and we don't trouble users to select files again but just return failure :(
I needed the same thing (almost). In my case I wanted the image inside the clickable area would be disable onmouseover. As I couldn't do it I made a workaround using a button which has the property clickable. You could make almost the same thing except you would hide/remove the button when your limit was reached :)
I faced a same problem but i achieved it by removing 'Dropzone owned element/form' and regenerate it again using JavaScript. This way all the registered events automatically remove :) simple thing
write enable and disable method in javascript. Example: disable = function(){ //make dropzone disable $('#file_area').empty(); // deleting registered dropzone $('#file_area').html('
'); // regenrating }//end of disable enable = function(){
previewaDropzone = new Dropzone("div#preview_2",
url: "/battles.json");
}
The solution I found was to make an extense use of events. If one disables the body>.dz-hidden-input the file browser doesn't show up.
I would love!!!! native support for this!
kuroisuna THANKS! best suggestion by far and it works on 4.0.1 !!! $(".dz-hidden-input").prop("disabled",true);
I'd love to see something like this as well!
For now you can also use pointer-events: none in CSS to disable the click event:
.dz-max-files-reached {
/* disable click event on main Dropzone element when max files are reached */
pointer-events: none !important;
}
.dz-max-files-reached * {
/* allow clicking on child elements (to remove files from Dropzone) */
pointer-events: all;
}
This is especially nice when dealing with virtual DOMs (e.g. in Vue).
@kuroisuna there is another problem,when one page has two dropzone control, your way do not work
This is a still existing issue.
I believe @AlexVanderbist workaround is the best way now