Vue-Dropzone setOption method not working

730 Views Asked by At

Im trying to set the url dynamically on a dropzone elements options. According to the documentation, you use the setOption method to change options after initialization.

So Im doing this...

var url ='http://myurl'
this.$refs.dropzone1.setOption('url', url)

But Im getting this error...

 Uncaught TypeError: Cannot read property 'options' of undefined
 at VueComponent.setOption (vue2Dropzone.js?2af3:1)

So then I tried doing this....

 var url ='http://myurl'
 this.$refs.dropzone1.dropzone.setOption('url', url)

and I got this...

 Uncaught TypeError: Cannot read property 'setOption' of undefined
 at VueComponent.setOption (vue2Dropzone.js?2af3:1)

Then I tried just setting the option directly, without the method, and that worked cuz it changes it. But it doesnt actually 'change' because its obviously inititialized already.

this.$refs.dropzone1.dropzone.options.url = url

How do I use setOption properly?? because apparently, using it the way the documentation states, doesnt work?

Maybe I have a broken version?? Im using v3.2.2

1

There are 1 best solutions below

2
On
Uncaught TypeError: Cannot read property 'options' of undefined
at VueComponent.setOption (vue2Dropzone.js?2af3:1)

This means you probably called setOption() before <vue-dropzone> was mounted.

(Because this.dropzone.options should be available after mounted() is called)

 Uncaught TypeError: Cannot read property 'setOption' of undefined

Calling setOption() on the dropzone property inside the component wouldn't work either because it also wouldn't be initialised yet and secondly because Dropzone.js doesn't have such a method.

Setting it directly also shouldn't work, or are you setting that at different time?