I succesfully parsed some photos from the server to repopulate a form Post. Now I need them to be displayed I have this code and with a firefox console the data is stored correctly in mockFile but when the time of pulling I got the myDrzone.emit is not a function. here is the code. (Im new to javascript)
init: function () {
$.get('/getphoto',{'key': $('[name=key]').val()},function(data){
var files = JSON.parse(data);
for (var i = 0; i < files.length; i++) {
var mockFile = {
url: files[i].url,
size: files[i].size,
name: files[i].name
};
var myDropzone = this;
myDropzone.emit("addedfile", mockFile); //here I get the error
myDropzone.emit("thumbnail", mockFile);
myDropzone.emit("success", mockFile);
var existingFileCount = 1; // The number of files already uploaded
myDropzone.options.maxFiles = myDropzone.options.maxFiles - existingFileCount;
}
});
I have the Jquery plugin set before the dropzone.js
I had to move
var myDropzone = this;
just after
init: function () {
to fix the problem. As Im new to Javascript I dont really know the process of declaring the variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With