我用的是dropzone.js文件上传器。一切正常,但一旦我上传,我想清除dropzone的拇指,并隐藏div包含dropzone。这就是问题所在。尽管我努力清理拇指,大拇指仍然留在原地。
我已经尝试了Dropzone.js站点上的所有建议,但似乎都不起作用。我可以使用它们的示例让单独的删除按钮工作,但不能有一个主删除按钮。是的,我也尝试过FAQ示例。我直接从教程中获取了代码,只是添加了对库的引用,但仍然无法移除拇指。
<!doctype html>
<html>
<head>
<link href="style/dropzone.css?v=1.2" type="text/css" rel="stylesheet" />
<script src="js/dropzone.min.js"></script>
<script language="javascript">
function ClearDZ() {
myDropzone.removeAllFiles();
document.getElementById("container").style.display = "none";
}
</script>
<meta charset="UTF-8">
</head>
<body>
<div id=container>
<form id="myDropzone" action="/target-url" class="dropzone"></form>
<button onclick="ClearDZ()">Clear All</button>
<div>
</body>
</html>发布于 2014-05-20 22:31:33
我想知道你的dropzone配置在哪里,你是如何配置它的。如果你的代码和你展示的一样简单,你应该配置你的dropzone并监听事件。试试这个:
<script>
//I'm assuming your form is called myDropzone
Dropzone.options.myDropzone = {
//your configuration goes here
init: function() {
var myDropzone = this;
//You can do this
$('#your_button_id').on("click", function(e) {
myDropzone.removeAllFiles(true);
});
//But you should do this
this.on("success", function(file, response) {
myDropzone.removeAllFiles(true);
});
//and this to handle any error
this.on("error", function(file, response) {
//handle errors here
});
}
}
</script>您可以在http://www.dropzonejs.com/#toc_8上获得有关侦听事件的更多信息,以及在http://www.dropzonejs.com/#toc_6上获得有关Dropzone配置的详细信息
我希望它对您有用:)
发布于 2017-06-05 10:51:06
在你的库dropzone dropzone.js上试一下,但将time out设置为自动关闭2500
success: function(file) {
if (file.previewElement) {
return file.previewElement.classList.add("dz-success"),
$(function(){
setTimeout(function(){
$('.dz-success').fadeOut('slow');
},2500);
});
}
},https://stackoverflow.com/questions/23744789
复制相似问题