Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
90
rated 0 times [  95] [ 5]  / answers: 1 / hits: 15819  / 9 Years ago, mon, february 16, 2015, 12:00:00

I want to add checkbox to dropzone images so that I can upload only the selected ones. I am going to add a checkbox next to each image when the addedfile event is fired.



I am using the following method to programmatically add images to dropzone:



var mockFile = { name: image.jpg, size: 12345 };
imgUrl = http://example.com/image.jpg
myDropzone.options.addedfile.call(myDropzone, mockFile);
myDropzone.options.thumbnail.call(myDropzone, mockFile, imgUrl);


The problem is that the addedfile event is not fired for images added this way:



myDropzone.on(addedfile, function(file) {
console.log(file added!); // this line is never printed
});


But if added an image by manually clicking on dropzone and selecting a file, the above event would fire. Why is this event not fired in the first case?


More From » jquery

 Answers
5

i had same issue and found the answer here from @enyo:
https://github.com/enyo/dropzone/issues/209



Basically the addedfile.call is a bit clumsy and you need replace this line by the following:



myDropzone.emit(addedfile, file);


This way the addedfile function is called properly.



Cheers


[#67804] Friday, February 13, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kamronr

Total Points: 749
Total Questions: 110
Total Answers: 122

Location: Dominica
Member since Sat, Nov 5, 2022
2 Years ago
kamronr questions
Mon, Dec 21, 20, 00:00, 3 Years ago
Fri, Oct 16, 20, 00:00, 4 Years ago
Sat, Oct 3, 20, 00:00, 4 Years ago
Sun, Jul 28, 19, 00:00, 5 Years ago
;