【问题标题】:How to run Dropzone processQueue() when not initiating programmatically?不以编程方式启动时如何运行 Dropzone processQueue()?
【发布时间】:2015-09-29 23:44:01
【问题描述】:

我试图通过将类添加到这样的表单来启动 dropzone:

<form class="dropzone ng-pristine ng-valid dz-clickable" id="photoDropzoneDiv" action="/panel/vehicles/3/photos" accept-charset="UTF-8" method="post">

现在 dropzone 可以工作了。接下来我将 dropzone 设置为不自动处理队列:

Dropzone.options.photoDropzone = {
    paramName: "file", // The name that will be used to transfer the file
    maxFilesize: 5, // MB
    autoProcessQueue: false,
    parallelUploads: 500,
    acceptedFiles: '.jpg,.jpeg,.JPEG,.JPG,.png,.PNG',
    addRemoveLinks: true,
    init: function(file, done) {
        this.on("queuecomplete", function(file) {
            this.removeAllFiles();
        });
    }
};

现在当我这样调用 processQueue 时:

photoDropzone.processQueue();

上面写着Uncaught TypeError: photoDropzone.processQueue is not a function。我该如何解决这个问题?

【问题讨论】:

    标签: dropzone.js


    【解决方案1】:

    这在这里工作:)

    $('#submit').click(function() {
        var myDropzone = Dropzone.forElement(".dropzone");
        myDropzone.processQueue();
    });
    

    【讨论】:

      【解决方案2】:
      Dropzone.options.addFiles = {
          maxFileSize : 4,
          parallelUploads : 10,
          uploadMultiple: true,
              autoProcessQueue : false,
          addRemoveLinks : true,
          init: function() {
              var submitButton = document.querySelector("#act-on-upload")
              myDropzone = this;
              submitButton.addEventListener("click", function() {
                  myDropzone.processQueue(); 
              });
              myDropzone.on("addedfile", function(file) {
                  if (!file.type.match(/image.*/)) {
                      if(file.type.match(/application.zip/)){
                          myDropzone.emit("thumbnail", file, "path/to/img");
                      } else {
                          myDropzone.emit("thumbnail", file, "path/to/img");
                      }
                  }
              });
              myDropzone.on("complete", function(file) {
                  myDropzone.removeFile(file);
              });
          },
      };
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-11-25
        • 2015-08-05
        • 1970-01-01
        • 2015-11-21
        • 1970-01-01
        • 2017-06-02
        • 1970-01-01
        相关资源
        最近更新 更多