Question

I'm using dropzone as a jquery plugin so I haven't instantiated using.

var myDropzone = new Dropzone("div#myId", { url: "/file/post"});

I've used this method.

$("div#myId").dropzone({ url: "/file/post" });

But I need to do this:

myDropzone.emit("addedfile", jsonFile);

I've tried

$("div#myId").emit("addedfile", jsonFile);

and i've tried

var myDropzone= $("div#myId").dropzone({ url: "/file/post" });

myDropzone.emit("addedfile", jsonFile);

I feel like this is some basic hole in my understanding of how these things work so an explanation of my error would also be much appreciated.

Many Thanks,

Paul

Était-ce utile?

La solution

Dropzone.forElement("div#myId").emit("addedfile", jsonFile);

Autres conseils

I created a function like so:

function foo(dz) {
    var jsonFile = {name: 'moo', size: 10}
    dz.emit('addedfile', jsonFile)
}

And called it like this:

$('#mydrop').dropzone({
  url: '/foo/bar',
  init: function() {
    var dz = this
    foo(dz)
  }
})

And then I was able to emit events from within foo()

Have a look at enyo's comment on jQuery instancing: Accessing Dropzone object.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top