0

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

Kylie
  • 11,421
  • 11
  • 47
  • 78

1 Answers1

0
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?

Bob Fanger
  • 28,949
  • 7
  • 62
  • 78
  • Im calling setOption long after vue-dropzone is mounted. The setOption is fired when I click a button. So the component is definitely mounted. As its visible. – Kylie Oct 09 '18 at 17:03
  • What a strange bug. Try `console.log(this.$refs.dropzone1)` and try finding out when the `` component doesn't have a dropzone property with a options property anymore. – Bob Fanger Oct 09 '18 at 19:50