我一直在试图弄清楚如何在dropzone.js中添加queuecomplete回调选项。我读过dropzone.js - how to do something after ALL files are uploaded,但它显示了几个选项,但我不知道在哪里/如何实现这个选项。我尝试在引用dropzone.js之后,在dropzone.js等中添加代码,但没有成功。我只是想让它变得简单,用最小的形式和下拉区域类。
我试过:
Dropzone.options.filedrop = {
init: function () {
this.on("complete", function (file) {
if (this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0) {
doSomething();
}
});
}
};而且还
this.on("queuecomplete", function (file) {
alert("All files have uploaded ");
});但是继续得到Dropzone是没有定义的。
我想我只需要知道如何实现这一点。
发布于 2015-07-21 20:03:24
您必须先添加JavaScript文件,然后再添加正在使用的脚本。
<script src="./path/to/dropzone.js"></script>
<script>
Dropzone.options.filedrop = {
init: function () {
this.on("queuecomplete", function (file) {
alert("All files have uploaded ");
});
}
};
</script>下面是一个不会给出错误的工作陷阱(您不能在堆栈溢出上上传,因为这个操作不存在)
Dropzone.options.filedrop = {
init: function () {
this.on("queuecomplete", function (file) {
alert("All files have uploaded ");
});
}
};<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.0.1/dropzone.js"></script>
<link rel="stylesheet" href="https://rawgit.com/enyo/dropzone/master/dist/dropzone.css">
<p>
This is the most minimal example of Dropzone. The upload in this example
doesn't work, because there is no actual server to handle the file upload.
</p>
<!-- Change /upload-target to your upload address -->
<form action="/upload-target" class="dropzone"></form>
注意:,如果您正在使用jQuery,您可以在$(document).ready(function { /* add here */ });中添加代码。
https://stackoverflow.com/questions/31548480
复制相似问题