如何使用 jQuery File Upload(Blueimp http://goo.gl/y1Y2b ) 为每个文件创建进度条?我有多个表格,每个表格都有一个上传按钮。
$('.fileupload').fileupload({
dataType: 'json',
add: function (e, data) {
var formContainer = $($(this).parent()).parent();
var file = data.files[0];
var li = $('<li/>').attr("id", 'li-upload-'+file.id).appendTo($(formContainer).children('.ul-files'));
var link= $('<a/>').attr("href", '#').attr("data-href", file.delete_url).addClass("link-remove-file pull-right").attr("target", "_parent").attr("title", "Remove").appendTo(li);
var ico = $('<i/>').addClass('icon-remove').appendTo(link);
var spn = $('<span/>').html(file.name+' ('+Math.round(file.size/1024)+' K)').appendTo(li);
var lod = $('<div/>').addClass('container-progress-upload').css("float", 'right').appendTo(li);
var prg = $('<div/>').addClass('bar').css("width", '0%').attr("id", 'pgr-'+file.name).appendTo(lod);
data.submit();
},
progress: function (e, data) {
var file = data.files[0];
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#pgr-'+file.name).css(
'width',
50 + '%'
);
}
});