admin管理员组文章数量:1312849
I'm using the dropzone.js
file uploader. Everything works fine but once I've uploaded I want to clear the dropzone of thumbs and hide the div containing dropzone. That's where things go awry. The thumbs still stay in place despite my efforts to clear them.
I've tried all the suggestions in the Dropzone.js site but nothing seems to work. I can get separate remove buttons to work using their example but can't have a master remove button. And yes, I've tried the FAQ example as well. I took the code straight from the tutorial and just added the references to the libraries and it still wouldn't remove the thumbs.
<!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>
I'm using the dropzone.js
file uploader. Everything works fine but once I've uploaded I want to clear the dropzone of thumbs and hide the div containing dropzone. That's where things go awry. The thumbs still stay in place despite my efforts to clear them.
I've tried all the suggestions in the Dropzone.js site but nothing seems to work. I can get separate remove buttons to work using their example but can't have a master remove button. And yes, I've tried the FAQ example as well. I took the code straight from the tutorial and just added the references to the libraries and it still wouldn't remove the thumbs.
<!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>
Share
Improve this question
edited May 20, 2014 at 10:09
user3200528
asked May 19, 2014 at 18:32
user3200528user3200528
631 gold badge1 silver badge8 bronze badges
5
- 1 And your problem is ? – Andrei Commented May 19, 2014 at 18:34
- 1 What HAVE you tried so that we're not giving duplicate suggestions you've already tried. What DOES happen when you've tried each method? – Lee S Commented May 19, 2014 at 19:04
- The thumbs stay visible in the dropzone form. They are supposed to be removed. When I set the display back to block, they are still there. – user3200528 Commented May 20, 2014 at 5:37
- Actually, with the syntax as is, even the div isn't hidden. Obviously a problem at the removeAllFiles line. I have tried using the separate remove buttons in the FAQ which uses _this.removeFile(file); That works for one file at a time. I tried a variation _this.removeAllFiles(); That did exactly the same thing: Removed one file but not all. Everything else has done absolutely nothing. – user3200528 Commented May 20, 2014 at 5:43
- Are you getting any errors in your console? – Andy Commented May 20, 2014 at 10:14
2 Answers
Reset to default 6I wonder where are your dropzone configuration and how did you configure it. If your code is as plain as you showed, you should configure your dropzone and listen to events. Try this:
<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>
You can have more information about listen to events at http://www.dropzonejs./#toc_8 and about configuration of Dropzone at http://www.dropzonejs./#toc_6
I hope you find it useful :)
try this on your library dropzone dropzone.js; but set time out to auto close 2500
success: function(file) {
if (file.previewElement) {
return file.previewElement.classList.add("dz-success"),
$(function(){
setTimeout(function(){
$('.dz-success').fadeOut('slow');
},2500);
});
}
},
本文标签: javascriptRemove dropzone of thumbs and hide the div containing dropzoneStack Overflow
版权声明:本文标题:javascript - Remove dropzone of thumbs and hide the div containing dropzone - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741901078a2403872.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论