单个页面中的多个Dropzone。

时间:2022-11-23 20:35:57

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

我使用Dropzone而没有创建Dropzone表单。这对我很有用。

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

但是在这种情况下,我不能在我的页面中创建另一个Dropzone实例。

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.

当我这样做的时候,我得到了已经附加的错误Dropzone。

1 个解决方案

#1


20  

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...

这是可能的,但是您不能像以前那样在同一个元素上绑定第二个dropdzone。一个元素上的两个dropzone没有意义。2 x文档。在你的自动取款机里。试试这个…

HTML:

HTML:

<form action="/file-upload" class="dropzone" id="a-form-element"></form>
<form action="/file-upload" class="dropzone" id="an-other-form-element"></form>

JavaScript:

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

#1


20  

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...

这是可能的,但是您不能像以前那样在同一个元素上绑定第二个dropdzone。一个元素上的两个dropzone没有意义。2 x文档。在你的自动取款机里。试试这个…

HTML:

HTML:

<form action="/file-upload" class="dropzone" id="a-form-element"></form>
<form action="/file-upload" class="dropzone" id="an-other-form-element"></form>

JavaScript:

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