5

I'm using dropzone.js for my project and I need to delete files from plugin upload zone (not from server) after I upload them. I need to get back to "Drop files here or click to upload" text after upload.

I'm trying to get same result that I would get when I'm using "Remove file" link under file icon. But when I try to achieve this programmatically the removeFileEvent won't trigger.

I tried both jquery trigger('click'); and dispatchEvent(event);.

My code:

 var dropzone = new Dropzone('#uploadzone', { url: 'uploaded_url.php', addRemoveLinks: true, init: function () { this.on("success", function (file, response) { var removeLink = $(file.previewElement).find('a.dz-remove'); removeLink.trigger('click'); }); } ); 
3
  • 1
    have you tried their API method?? like dropzone.removeFile(file) Commented Dec 16, 2015 at 9:23
  • Nope, Didn't noticed that part in documentation. Tried it and it works. Thanks ! Commented Dec 16, 2015 at 9:35
  • 1
    I will make it as answer so that it will be helpful for others. Commented Dec 16, 2015 at 9:39

1 Answer 1

2

You can use the API given by dropzone

dropzone.removeFile(file)

Docs

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.