ris*_*shy 14 javascript jquery
我正在使用http://www.dropzonejs.com/(dropzone.js)库.我初始化了我的一个表单元素,
var drop = $("#upload").dropzone({
uploadMultiple: "true",
addRemoveLinks: "true",
thumbnailWidth: "250",
thumbnailHeight: "250",
maxFilesize: "10",
headers: {
"title": titles,
"location": locations,
"tag": tags
}
});
Run Code Online (Sandbox Code Playgroud)
现在,当用户点击<button id="close"></button>按钮时,我想使用该drop.removeAllFiles(true)功能清空整个列表,如Dropzone.js官方网站上所示.
所以,我尝试过使用
$("#close").click(function(){
drop.removeAllFiles(true);
});
Run Code Online (Sandbox Code Playgroud)
但它没有用,console.log我收到了错误removeAllFiles() is not declared for drop.
我哪里错了?
Duc*_*ain 52
这对我有用.
Dropzone.forElement("#YourDropBoxId").removeAllFiles(true);
Run Code Online (Sandbox Code Playgroud)
参考:https://github.com/enyo/dropzone/issues/180
Dil*_*mar 11
这是代码,它将解决您的问题.
$(function() {
Dropzone.options.myAwesomeDropzone = {
init: function () {
var myDropZone = this;
$("#btnRemoveAll").click(function () {
myDropZone.removeAllFiles();
}
);
}
};
});
Run Code Online (Sandbox Code Playgroud)