Reputation: 618
I want to pass multiple values to a function in uploadify.
The way you call a function is like this
$("#id").uploadify("upload", fileId);
here fileId is id of only one file to be uploaded.
I have a scenario where i itertate over a table to get file ids to upload then i want to pass those ids to this function call. How can i do that.
and here is currently what i am doing, which obviously isn't working.
var imagesToUpload = [];
$.each(data.validationResult, function (index, obj) {
var imageToUpload = GetFileToUpload(obj.ImageName);
if(imageToUpload){
imagesToUpload[imageToUpload] = imageToUpload;
}
});
$("#id").uploadify("upload", imagesToUpload);// this is not working
Upvotes: 0
Views: 58
Reputation: 15415
You can use Function.prototype.apply()
to pass arguments to a function as an array.
$('#id').uploadify.apply(null, ['upload'].concat(imagesToUpload));
This assumes that imagesToUpload
is an Array of the arguments you want to pass.
Upvotes: 1