I am using: https://github.com/blueimp/jQuery-File-Upload (the basic plugin, without the ui addition)
I'm using data.context to tie link individual nodes to update the progress of each file upload, but it won't update the last one loaded. So for example if I choose 4 files, they will display on my page and the progress will work for the first 3 in the list, but not the 4th. Regardless of number selected, it's always the last one in the list. (if only 1 item is selected it works ok).
In addition it also appears that it's also not updating the relevant progress bar.
Any ideas?
Here's my code:
$('.aws').fileupload({
limitMultiFileUploads: 1,
dataType: 'html',
add: function (e, data) {
var file = data.files[0];
var fileDetails = '<tr><td>' +
file.name +
'</td><td class="progress"><span class="progress"><span class="js-progress-active progress-active"></span>' +
'</span></td><td class="cancel-file"><a href="#" class="cancel-file-load-icon js-cancel-file">Cancel</a></td></tr>';
if ($('.file-list table tr:last').length > 0) {
data.context = $('.file-list table tr:last').after(fileDetails);
} else {
data.context = $(fileDetails).appendTo('.file-list table');
}
data.submit();
},
progress: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
data.context.find('.js-progress-active').css(
'width',
progress + '%'
).text(progress + '%');
}
})
UPDATE Turns out it's the 'tr:last' selector. so this doesn't work:
data.context = $('.file-list table tr:last').after(fileDetails);
but this does:
data.context = $(fileDetails).appendTo('.file-list table');
fileDetails
is atr
string, this should work as well:data.context = $(fileDetails).insertAfter( $(".file-list table tr").last() );
– Sanjiv