Vue-dropzone: Every time the page with dropzone is visited, a new input element for file upload is created.

Created on 21 Jun 2017  路  3Comments  路  Source: rowanwins/vue-dropzone

A "create a new task" page has a dropzone element. Every time the page is visited, a new input element for file upload is created.

<input type="file" multiple="multiple" class="dz-hidden-input" style="visibility: hidden; position: absolute; top: 0px; left: 0px; height: 0px; width: 0px;">
<input type="file" multiple="multiple" class="dz-hidden-input" style="visibility: hidden; position: absolute; top: 0px; left: 0px; height: 0px; width: 0px;">

How the duplication is avoided?

Cheers,
Zhen

Most helpful comment

Hi @zhangzhen

Currently the element is created using the mounted event which if you're using a single page app or something with lots of tabs etc might be resulting in the duplication i think.

We could possibly move the creation to the created lifecycle event.... this would possibly get around the duplication issue.

At the moment there is no real way to control this.

All 3 comments

Hi @zhangzhen

Currently the element is created using the mounted event which if you're using a single page app or something with lots of tabs etc might be resulting in the duplication i think.

We could possibly move the creation to the created lifecycle event.... this would possibly get around the duplication issue.

At the moment there is no real way to control this.

I noticed this issue earlier on my site. I had about 20 hidden elements in the DOM from navigating back and forth to pages with dz's.

Can you add the below code to the components destroyed method? This solved it for me on the views that use dropzone.

document.querySelectorAll('input.dz-hidden-input').forEach(function (elem) { elem.parentNode.removeChild(elem) })

Best,
Sam

Thanks for the suggestion @stoked74 - we'll see if we can with this in

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jd-0001 picture jd-0001  路  5Comments

stevenhardy-digital picture stevenhardy-digital  路  4Comments

bruno-fernandes picture bruno-fernandes  路  4Comments

ServerJunge picture ServerJunge  路  5Comments

vesper8 picture vesper8  路  4Comments