[Vuejs]-How upload file using dropzone & vueJs

0πŸ‘

  • move the function into your methods so you can access the vm via this
  • use new Dropzone() to create the Dropzone instance instead of $().dropzone?
  • save the new instance as a vm property instead of a variable
  • access it in other methods through that property

Like this:

var vmGallery = new Vue({

  el: '#GalleryController',
  data: {},

  methods: {
      AddGallery() {
        console.log('add');
        // access dropzone instance through vm property
        this.uploadImageGalleryVar.options.autoProcessQueue = true;
        this.uploadImageGalleryVar.processQueue();
      },

      // move function into yor methods.
      uploadImageGallery() {
        Dropzone.autoDiscover = false;
        // save dropzone instance as vm property
        // use new Dropzone() to create it instead of jQuery shortcut
        this.uploadImageGalleryVar = new Dropzone($(".upload__button__news"), {
          url: base_url + "/myRoute",
          addRemoveLinks: true,
          dictCancelUpload: "",
          autoProcessQueue: false,
          dictRemoveFile: "x"
        });
      }
  },

  ready: function() {
    uploadImageGallery();
  }
});

That’s it

πŸ‘€Linus Borg

Leave a comment