单击按钮后如何在Dropzone.js中调用.removeAllFiles()函数 [英] How to call the .removeAllFiles() function in Dropzone.js after a click on a button
问题描述
我正在使用 http://www.dropzonejs.com/ (dropzone.js)库。我初始化了我的一个表单元素,
I am using the http://www.dropzonejs.com/ (dropzone.js) library. I have initialized one of my form element as,
var drop = $("#upload").dropzone({
uploadMultiple: "true",
addRemoveLinks: "true",
thumbnailWidth: "250",
thumbnailHeight: "250",
maxFilesize: "10",
headers: {
"title": titles,
"location": locations,
"tag": tags
}
});
现在,当用户点击< button id =close> ;< / button>
按钮,我想使用 drop.removeAllFiles(true)
函数清空整个列表,如Dropzone所示。 js官方网站。
Now when user clicks on a <button id="close"></button>
button, I want to empty the whole list using the drop.removeAllFiles(true)
function, as suggested on Dropzone.js official website.
所以,我尝试使用
$("#close").click(function(){
drop.removeAllFiles(true);
});
但它不起作用,在 console.log
我收到错误 removeAllFiles()未声明为drop
。
But it's not working, In console.log
I am getting the error removeAllFiles() is not declared for drop
.
我哪里错了?
推荐答案
这对我有用。
Dropzone.forElement("#YourDropBoxId").removeAllFiles(true);
参考: https://github.com/enyo/dropzone/issues/180
这篇关于单击按钮后如何在Dropzone.js中调用.removeAllFiles()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!