【发布时间】:2016-02-08 09:16:29
【问题描述】:
我需要将拖放/可点击和预览区域从<form> 移动到一个单独的 div 容器中,这样我就可以使用普通表单了。
问题是我设置了这两个选项但没有任何反应,它仍然将整个表单显示为区域(在 jsfiddle 中至少是可点击的,但在我的页面中不是)。
这是我正在使用的 html 代码(是的,dropzone 是一个带有样式的 css 类):
<form id="myAwesomeDropzone" class="dropzone" action="index.php">
<div class="option img">
<p>Imagenes (máximo 6):</p>
<div id="dropzone">
<div class="dropzone-previews"></div>
</div>
</div>
// more form
</form>
这是dropzone代码:
Dropzone.options.myAwesomeDropzone = {
paramName: "file",
acceptedFiles: 'image/*',
addRemoveLinks: true,
parallelUploads: 6,
maxFilesize: 6,
maxFiles: 6,
autoDiscover: false,
autoProcessQueue: false,
uploadMultiple: true,
previewsContainer: '.dropzone-previews',
clickable: '.dropzone-previews',
// The setting up of the dropzone
init: function() {
var myDropzone = this;
// First change the button to actually tell Dropzone to process the queue.
this.element.querySelector("button[type=submit]").addEventListener("click", function(e) {
// Make sure that the form isn't actually being sent.
e.preventDefault();
e.stopPropagation();
myDropzone.processQueue();
});
// Listen to the sendingmultiple event. In this case, it's the sendingmultiple event instead
// of the sending event because uploadMultiple is set to true.
this.on("sendingmultiple", function() {
// Gets triggered when the form is actually being sent.
// Hide the success button or the complete form.
});
this.on("successmultiple", function(files, response) {
// Gets triggered when the files have successfully been sent.
// Redirect user or notify of success.
alert(response);
});
this.on("errormultiple", function(files, response) {
// Gets triggered when there was an error sending the files.
// Maybe show form again, and notify user of error
alert(response);
});
}
};
【问题讨论】: