2015-07-11 11 views
7

Im cố gắng để bắt đầu vùng thả bằng cách thêm các lớp mẫu như thế này:Làm thế nào để chạy Dropzone processQueue() khi không bắt đầu lập trình?

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

Bây giờ dropZone công trình. Tiếp theo, tôi thiết lập vùng thả không để quá trình tự động hàng đợi:

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(); 
     }); 
    } 
}; 

Bây giờ khi tôi gọi processQueue như thế này:

photoDropzone.processQueue(); 

Nó nói Uncaught TypeError: photoDropzone.processQueue is not a function. Làm thế nào tôi có thể sửa lỗi này?

+0

bạn đã giải quyết nó? – Lomithrani

Trả lời

17
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); 
     }); 
    }, 
}; 
8

Funcionou aqui:)

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

Điều này đơn giản hơn nhiều và hiệu quả với tôi – Mazaryk

Các vấn đề liên quan