Vote count:
0
I loop through files dragged in to the window:
$.each(files, function(index, file){
p.readFile(file).done(p.showFile);
});
They are read via this method:
p.readFile = function(file) {
var fileReader = new FileReader();
var deferred = $.Deferred();
fileReader.onload = function(event) {
deferred.resolve(event.target.result);
};
fileReader.onerror = function() {
deferred.reject(this);
};
fileReader.readAsDataURL(file);
return deferred.promise();
};
Once read files are passed to this method:
p.showFile = function(file, index) {
};
My question concerns the first loop:
$.each(files, function(index, file){
p.readFile(file).done(p.showFile);
});
I need to pass the index of the loop and the returned file from the promise to the p.showFile method, how would I do this?
asked 33 secs ago
Aucun commentaire:
Enregistrer un commentaire