diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 8fbaa5981..bbaf18bb4 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -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) { $('', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 254, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload), $('公开:').attr({ 'class': 'ispublic-label' }) , $('', { 'type': 'checkbox', 'class': 'is_public_checkbox','value':1, 'name': 'attachments[' + attachmentId + '][is_public_checkbox]', checked:'checked' } ).toggle(!eagerUpload), - $(' ').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload), + $(' ').attr({ 'href': "#", 'class': 'remove-upload' }).click(function(){ + if(confirm('您确定要删除吗?')){ + removeFile(); + if(!eagerUpload){ + (function(e){ + reload(e); + })(fileSpan); + } + } + + }).toggle(!eagerUpload), $('