2014-04-10 6 views
5

so heren meinen Code:Dropzone.js Entfernen von Dateien, nachdem ein Ereignis ausgelöst wird

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. 
     myDropzone.removeAllFiles(); 
     console.log("a"); 

    }); 

// 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. 
}); 

} };

Wie kann ich removeAllfiles nach dem Klicken auf den Upload-Button hinzufügen. Dank

Antwort

10

sollte diese Arbeit:

Dropzone.options.myDropzone = { 

    autoProcessQueue: false, 

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

    submitButton.addEventListener("click", function() { 
     myDropzone.processQueue(); 
    }); 

    // Execute when file uploads are complete 
    this.on("complete", function() { 
     // If all files have been uploaded 
     if (this.getQueuedFiles().length == 0 && this.getUploadingFiles().length == 0) { 
     var _this = this; 
     // Remove all files 
     _this.removeAllFiles(); 
     } 
    }); 

    } 

}; 

Durch this.on("complete", function() { //Code to be executed }); verwenden Sie können Ihren Code auszuführen, sobald die Dateien hochgeladen wurden. In Ihrem Fall können Sie alle Dateien entfernen.

+0

danke. arbeitete wie ein Charme hehe –

+0

Kein Problem :) jederzeit – BenEgan1991

Verwandte Themen