I am experiencing issues with the jQuery File Uploader (blueimp):
My implementation is fully customized. I use image previews and validation.
My problem is that even though i am defining data.context in my fileuploadadd event, it comes in empty when fileuploadprogress is fired.
$('fileinput-element').fileupload({
url: '/__module/uploadModule/receive',
type: 'post',
acceptFileTypes: acceptedFileRegEx,
dataType: 'json',
'dropZone': $(dropZone),
paramName: 'files',
autoUpload: false,
}).on('fileuploadadd', function (e, data) {
$.each(data.files, function (index, file) {
// NOTE: This function call returns a clone of an element that i use as template for upload list items. Works fine.
var component=uploadModule.getDynamicComponent('listItemContainer');
// Filling the template (code omitted due to better readabilty)
// Appending the component to my #uploadList and assigning that to data.context
data.context = component.appendTo('#uploadList');
});
// For manual submittion later on, i fill an array with the data objects from each event call
dataList.push(data);
}).on('fileuploadprocessalways', function(e,data){
var index = data.index,
file = data.files[index],
node = $(data.context.children()[index]);
// Further code ommitted due to readability. Here i apply file.preview and (potential) file.error to my list item that is now stored in the variable node. This works fine. My list renders perfectly well.
}).on('fileuploadprogress', function(e, data){
// PROBLEM: data.context is EMPTY ! Why???
console.log(data.context);
});
And this is how i submit everything upon clicking a start upload button:
$(dataList).each(function(){
this.submit();
});
// This works well - the uploads are being submitted and sent to the server.
I have done extensive solution searching, testing, trial & error, debugging for 1.5 days now. I just can't wrap my head around this.
What am i doing wrong?
Please note: If i do a data.submit() right inside the add event callback, then data.context is filled correctly when the progress event fires, but i am no longer left with the option of manually launching the entire upload queue.