Hi guys,
I am busy with an MVC project and my JS knowledge is clearly lacking.
What I am trying to do is to populate a Dropzone.js control with files that have already been uploaded to the server as per https://github.com/enyo/dropzone/wiki/FAQ
the JS initialization code is as follows:
I receive the right responses from the server, but no matter what I have tried, the imageFiles array stays bank.
Once the array has been generated with all the correct details, I want to pass it on to the DropZone initialization to create Mock files, but since the imageFiles array stays blank, I never see anything further.
I am busy with an MVC project and my JS knowledge is clearly lacking.
What I am trying to do is to populate a Dropzone.js control with files that have already been uploaded to the server as per https://github.com/enyo/dropzone/wiki/FAQ
the JS initialization code is as follows:
Code:
var EditFormInit = function (imageIds) {
var imageIdsArr = imageIds.split(",");
var imageFiles = [];
imageIdsArr.forEach(function (ImageId) {
var requestData = { imageId: parseInt(ImageId) };
$.ajax({
type: "POST",
url: "/Admin/PropertyImage/GetImageInfo",
data: requestData,
success: function (data, status, jqXHR) {
var image = { fileName: data.fileName, size: data.size, thumbnail: data.thumbnailURI };
return imageFiles.push(image);
}
});
});
I receive the right responses from the server, but no matter what I have tried, the imageFiles array stays bank.
Once the array has been generated with all the correct details, I want to pass it on to the DropZone initialization to create Mock files, but since the imageFiles array stays blank, I never see anything further.
Code:
Dropzone.options.propertyImages = {
url: "/admin/PropertyImage/UploadPropertyImages",
acceptedFiles: "image/*",
uploadMultiple: true,
addRemoveLinks: true,
maxFiles: 20,
init: function () {
imageFiles.forEach(function (image, index) {
var mockFile = { name: image.fileName, size: image.size }
this.emit("addedfile", mockFile);
this.emit("thumbnail", mockfile, image.thumbnailURI)
});