简体   繁体   中英

Can't click on DropZone upload button programmatically

I have some upload button:

<span id="upload" class="button dropzone-click-upload">
</span>

I am attaching clickable event in DropZone for it:

  this.dropZone = new Dropzone(this.someID, {
.
.
.
    clickable: '.dropzone-click-upload',

and it works when I am clicking on button physically, but for some reason I can't click on it programmatically. I've tried next cases:

    $('#upload').trigger('click');                                                            
    $('#dropzone-click-upload').click();                                                                 
    $('.dropzone-click-upload')[0].click();
    $(document).on ("click", "#upload", function () {
    });
    var elem = dropZoneInstance.clickableElements[0];
    elem.click();

How about something like this: Just a guess not tested

setTimeout(function() {
        $(elem).trigger("click");
    }, 100);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM