You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Matias Meno edited this page Jul 27, 2020
·
7 revisions
This tutorial shows you how to create a button that will remove all files from a dropzone.
<formid="my-dropzone" action="/target-url" class="dropzone"></form><buttonid="clear-dropzone">Clear Dropzone</button><scriptlanguage="javascript">// myDropzone is the configuration for the element that has an id attribute// with the value my-dropzone or myDropzoneDropzone.options.myDropzone={init: function(){this.on("sending",function(file){alert('Sending the file'+file.name)});// Using a closure.var_this=this;// Setup the observer for the button.document.querySelector("button#clear-dropzone").addEventObserver("click",function(){// Using "_this" here, because "this" doesn't point to the dropzone anymore_this.removeAllFiles();// If you want to cancel uploads as well, you// could also call _this.removeAllFiles(true);});}};</script>