dropzone icon indicating copy to clipboard operation
dropzone copied to clipboard

Disabling clickable does not work

Open juliandormon opened this issue 13 years ago • 11 comments

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

juliandormon avatar Aug 06 '13 14:08 juliandormon

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.

enyo avatar Aug 06 '13 14:08 enyo

It is indeed a must-have requirement and we don't trouble users to select files again but just return failure :(

sunblognuke avatar Nov 03 '13 14:11 sunblognuke

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 :)

amandasantanati avatar May 07 '14 17:05 amandasantanati

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

asad-ali-bhatti avatar Sep 16 '14 14:09 asad-ali-bhatti

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.

axeladriant avatar Nov 12 '14 01:11 axeladriant

I would love!!!! native support for this!

davewgeurts avatar Feb 18 '15 06:02 davewgeurts

kuroisuna THANKS! best suggestion by far and it works on 4.0.1 !!! $(".dz-hidden-input").prop("disabled",true);

davewgeurts avatar Feb 18 '15 06:02 davewgeurts

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).

AlexVanderbist avatar Nov 16 '17 16:11 AlexVanderbist

@kuroisuna there is another problem,when one page has two dropzone control, your way do not work

wanjun123 avatar Mar 26 '19 02:03 wanjun123

This is a still existing issue.

Jtmw11 avatar Oct 29 '19 18:10 Jtmw11

I believe @AlexVanderbist workaround is the best way now

axeladriant avatar Dec 31 '19 00:12 axeladriant