【问题标题】:Dropzone autoProcessQueue: false not workingDropzone autoProcessQueue:假不工作
【发布时间】:2017-10-11 16:08:20
【问题描述】:

我正在尝试通过单击按钮上传文件。

我已经关注了很多教程/问题,例如, Upload all files with a buttonDropzone.js post request in laravel 5.4。但是没有成功。

这是我的视图文件代码,

<form action="{{ url('admin/candidate/file-upload') }}" method="post" class="dropzone" id="my-dropzone">
    {{ csrf_field() }}
    <div class="dz-message">
        <h3>Drop images here or click to upload.</h3>
    </div>
</form>

这是我的 JS 文件代码(在文档就绪块中),

//DropZone - Drag and drop file upload
Dropzone.options.myDropzone = {
    // Prevents Dropzone from uploading dropped files immediately
    autoProcessQueue: false,

    init: function () {
        var submitButton = document.querySelector("#submit-all")
        myDropzone = this; // closure

        submitButton.addEventListener("click", function () {
            myDropzone.processQueue(); // Tell Dropzone to process all queued files.
        });
        // You might want to show the submit button only when 
        // files are dropped here:
        this.on("addedfile", function () {
            // Show submit button here and/or inform user to click it.
        });
    }
};

但我认为我的这个 js 文件块没有执行。应该是什么问题?

【问题讨论】:

  • 能否请您简要说明一下,您在控制台中遇到了什么错误。

标签: jquery dropzone.js laravel-5.4


【解决方案1】:

这不起作用:

$(function(){ Dropzone.options.myDropzone = {...} }

这行得通:

Dropzone.options.myDropzone = {...}

...只要它是在 DOM 加载之前执行的。

【讨论】:

    【解决方案2】:

    我遇到了同样的情况,发现代码:

    Dropzone.options.myDropzone = { .. }
    

    觉得没什么用。相反,我使用:

    Dropzone.forElement(".dropzone").options.autoProcessQueue = false;
    

    之后,当我需要排队时:

    Dropzone.forElement(".dropzone").processQueue();
    

    【讨论】:

      猜你喜欢
      • 2013-10-01
      • 2017-08-14
      • 1970-01-01
      • 1970-01-01
      • 2014-10-01
      • 1970-01-01
      • 2023-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多