Multiple Dropzone in a single page

I'm using Dropzone without creating a dropzone form. It works great for me in this way.

But in this case I can not create another instance of Dropzone in my page.

var myDropzone1 = new Dropzone( document.body, { url : "upload1"... . . . some parameters };
var myDropzone2 = new Dropzone( document.body, { url : "upload'"... . . . some parameters };

When I do this, I'm getting the error Dropzone already attached.

1

2 Answers

It's possible, but you can't bind a second dropdzone on the same element, as you did. 2 Dropzones on one element makes no sense. 2x document.body in your solution atm. Try this...

HTML:

<form action="/file-upload"></form>
<form action="/file-upload"></form>

JavaScript:

var myDropzoneTheFirst = new Dropzone( //id of drop zone element 1 '#a-form-element', { url : "uploadUrl/1" } );
var myDropzoneTheSecond = new Dropzone( //id of drop zone element 2 '#an-other-form-element', { url : "uploadUrl/2" } );
4

I want to add something here because I have experienced problems with multiple dropzones on the same page.

In your init code you must remember to include var if putting a reference otherwise it isn't dealing with this instance of the dropzone rather trying to access/relate to the others.

Simple javascript but makes a big difference.

init: function(){ var dzClosure = this; $('#Btn').on('click',function(e) { dzClosure.processQueue(); });

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like