【问题标题】:previewsContainer and clickable options not working in dropzone预览容器和可点击选项在 dropzone 中不起作用
【发布时间】: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);
    });
    }
};

http://jsfiddle.net/enr8jg3o/1/

【问题讨论】:

    标签: javascript dropzone.js


    【解决方案1】:

    你写的 HTML,做它应该做的。它也只是将文件图标(预览)和可点击区域的位置移动到那个新的 div,但我不认为 Dropzone.js 中有一个选项可以移动可掉落区域。 Bythewhy ,你可以使用没有那个 div 的普通形式。

    【讨论】:

      猜你喜欢
      • 2015-05-29
      • 2017-10-10
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-28
      • 2017-11-07
      • 2013-08-04
      相关资源
      最近更新 更多