简体   繁体   English

dropzone.js删除点击以上传

[英]dropzone.js remove click to upload

I am using the dropzone.js plugin for a project. 我正在为项目使用dropzone.js插件。 I'm wondering if there is a way to stop the click event (where you can select a file) but keep the drag and drop function. 我想知道是否有一种方法可以停止click事件(可以在其中选择文件),但是保留拖放功能。

The drag and drop are on our entire page and the click is getting annoying when you are just selecting text. 拖放在我们的整个页面上,当您仅选择文本时,单击变得很烦人。

I have tried 我努力了

$('.dropzone')[0].removeEventListener('click', myDropzone.listeners[1].events.click);

and

$(".dz-hidden-input").prop("disabled",true);

but these disable the drag and drop which I still need to work. 但是这些禁用了我仍然需要工作的拖放操作。 Any ideas? 有任何想法吗?

You can set the clickable option to false when initializing the Dropzone. 初始化Dropzone时,可以将clickable选项设置为false According to the DOCS 根据DOCS

If true, the dropzone element itself will be clickable, if false nothing will be clickable. 如果为true,则dropzone元素本身将是可单击的;如果为false,则将不可单击。

You can also pass an HTML element, a CSS selector (for multiple elements) or an array of those. 您还可以传递HTML元素,CSS选择器(用于多个元素)或这些元素的数组。 In that case, all of those elements will trigger an upload when clicked. 在这种情况下,所有这些元素都将在单击时触发上载。

See demo below 请参阅下面的演示

 // Dropzone class: $("div#myDZ").dropzone({ url: "/file/post", clickable: false }); 
 #myDZ { padding: 10px; width: 100%; height: 100vh; border: 2px inset #c8c8c8; font-family: Calibri; font-size: 14px; font-weight: bold; text-align: center; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.4.0/min/dropzone.min.js"></script> <div id="myDZ"> Drag / Drop your files here . Click is <kbd>DISABLED</kbd> and wont work </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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