#2082 IE8浏览器--任意模块上传附件:上传附件后,“未上传文件”字样并未随着附件的上传变成“已上传X个文件”

This commit is contained in:
guange 2015-03-23 18:06:53 +08:00
parent 7decf34cc7
commit 1126d9b9a9
1 changed files with 25 additions and 3 deletions

View File

@ -12,6 +12,17 @@ function postUpMsg(attachmentId)
})
}
function reload(fileSpan) {
fileSpan.remove();
$('#upload_file_count').html("未上传文件");
$old_file = $("#_file");
$new_file = $old_file.clone(true);
$old_file.replaceWith($new_file);
$new_file.show();
}
function addFile(inputEl, file, eagerUpload) {
if ($('#attachments_fields').children().length < 10) {
@ -25,7 +36,17 @@ function addFile(inputEl, file, eagerUpload) {
$('<input>', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 254, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload),
$('<span >公开:</span>').attr({ 'class': 'ispublic-label' }) ,
$('<input>', { 'type': 'checkbox', 'class': 'is_public_checkbox','value':1, 'name': 'attachments[' + attachmentId + '][is_public_checkbox]', checked:'checked' } ).toggle(!eagerUpload),
$('<a>&nbsp</a>').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload),
$('<a>&nbsp</a>').attr({ 'href': "#", 'class': 'remove-upload' }).click(function(){
if(confirm('您确定要删除吗?')){
removeFile();
if(!eagerUpload){
(function(e){
reload(e);
})(fileSpan);
}
}
}).toggle(!eagerUpload),
$('<div>', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} )
).appendTo('#attachments_fields');
@ -168,14 +189,15 @@ function addInputFiles(inputEl) {
if (inputEl.files) {
// upload files using ajax
uploadAndAttachFiles(inputEl.files, inputEl);
// $(inputEl).remove();
// $(inputEl).remove();
} else {
// browser not supporting the file API, upload on form submission
var attachmentId;
var aFilename = inputEl.value.split(/\/|\\/);
attachmentId = addFile(inputEl, { name: aFilename[ aFilename.length - 1 ] }, false);
if (attachmentId) {
$(inputEl).attr({ name: 'attachments[' + attachmentId + '][file]', style: 'display:none;' }).appendTo('#attachments_' + attachmentId);
$(inputEl).attr({ name: 'attachments[' + attachmentId + '][file]'}).hide();
$('#upload_file_count').html("已上传"+"<span id=\"count\">"+1+"</span>"+"个文件");
}
}