2014-05-19 34 views
0

我正在使用dropzone.js文件上传器。一切工作正常,但一旦我上传我想清除拇指的dropzone并隐藏包含dropzone的div。这就是事情出错的地方。尽管我努力清除它们,拇指仍然保持在原位。删除大拇指dropzone并隐藏包含dropzone的div

我已经尝试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> 
+1

而你的问题是? – Andrei

+1

你有什么尝试,以便我们不会给你已经尝试过的重复建议。当你尝试过每种方法时会发生什么? –

+0

拇指在dropzone表单中保持可见状态。他们应该被删除。当我将显示设置回阻止时,它们仍然存在。 – user3200528

回答

6

我想知道你的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

悬浮窗的配置,我希望你觉得它有用:)

+0

仍然没有得到它的工作。这里是整个文件: – user3200528

+0

嗯。我将

0

试试这个在您的图书馆悬浮窗dropzone.js;但设置时间自动关闭2500

success: function(file) { 
    if (file.previewElement) { 
     return file.previewElement.classList.add("dz-success"), 
     $(function(){ 
     setTimeout(function(){ 
      $('.dz-success').fadeOut('slow'); 
     },2500); 
     }); 
    } 
    },