How to make only the Dropzone.js Previews Div clickable and not the whole form

前端 未结 3 846
轻奢々
轻奢々 2021-02-02 16:55

I have to use dropzone.js form, which sends a couple of inputs and a file upload info to the other page.

My dropzone code looks like this -- >

Dropzone.         


        
3条回答
  •  别那么骄傲
    2021-02-02 17:36

    Alternatively you can create dropzones programmaticaly (even on non form elements) by instantiating the Dropzone class http://www.dropzonejs.com/#toc_4

    You need to add the dz-clickable class to your desired element.

    HTML

    Drop files here to upload

    JavaScript

    // Dropzone class:
    var myDropzone = new Dropzone("div#myDrop", { url: "/file/post"});
    
    // If you use jQuery, you can use the jQuery plugin Dropzone ships with:
    $("div#myDrop").dropzone({ url: "/file/post" });
    

    Note

    If you receive a console error saying: Dropzone already attached, make sure to add this line before initiating your new Dropzone object.

    Dropzone.autoDiscover = false;
    

提交回复
热议问题