Vue-dropzone: Remove event emitted on component destruction

Created on 23 Oct 2017  Â·  10Comments  Â·  Source: rowanwins/vue-dropzone

Whenever the component is destroyed it emits the remove event. I am using a custom template and listening to remove event to delete the file from the server. Now whenever the component is re-rendered, the file gets wiped.

Most helpful comment

Adding

:destroyDropzone="false"

Does make the problem go away. Since Turbolinks properly tears down vue components then this should be ok

All 10 comments

Seems like an issue with dropzone https://github.com/enyo/dropzone/issues/1175

I tried listening to the destroy event from the parent component, but it looks like the dropzone is destroyed before the hooks are fired in the parent. What I did for now is:

 onRemovedFile: function (file, error, xhr) {
   if (this.$children[0]._isBeingDestroyed) {
      // Dropzone has a bug that removes the file on destruction
      // https://github.com/enyo/dropzone/issues/1175
      return;
   }

   // delete file
}

Hi @hypeJunction

Yep this has been reported and is resolved in the v3 branch, see discussion here
https://github.com/rowanwins/vue-dropzone/issues/217

Ah interesting.

I also commented about this issue here:

https://github.com/rowanwins/vue-dropzone/issues/85#issuecomment-338983166

And more or less when is going to publised v3?

Looking forward to it.

Hi @FrancescoMussi & @hypeJunction

Version 3 is now released. Check out the docs for more info including a property to stop the destroy event being fired.

@rowanwins I am using

├─┬ [email protected]
│ └── [email protected]

And this is still happening. I am using Turbolinks which may have something to do with it

Adding

:destroyDropzone="false"

Does make the problem go away. Since Turbolinks properly tears down vue components then this should be ok

I am also using 3.5.2 version,
But still facing same problem.
Solved using
:destroyDropzone="false"
@vesper8 thanks

I am also on 3.5.2 and encountered the same problem which was solved by using the prop :destroyDropzone="false". Perhaps the docs could be a bit clearer on this point.

It's a great wrapper! Thanks for your hard work @rowanwins

:destroyDropzone="false" resolved it! I feel sorry for the next person this trips up!

Was this page helpful?
0 / 5 - 0 ratings