如何从选定的表格行中删除 qq 上传器

How to remove qq-uploader from selected table row?

本文关键字:删除 qq 表格      更新时间:2023-09-26

我正在我的MVC 3应用程序中开发文件上传功能。我让它正常工作(有点),当我尝试删除 qq-uploader 类时,问题出在 onComplete 函数中,它从所有检查的表格单元格中删除。工作流程如下,用户选中多个复选框,"上传文件"btn 出现在选中的每一行中,但是一旦在一行中完成一个上传,'qq-uploader 类将从所有单元格中删除,而不仅仅是上传文件的单元格。

有问题的表格行单元格:

     @if (Model.ElementAt(index).CertName != null)
             {
                 <td>@Html.DisplayFor(m => Model.ElementAt(index).CertName)</td>
             }
             else
             {                  
                <td id ="attBtn" class="file-uploader-attachment-Class"></td>
             }

视图中使用的脚本:

  <script type="text/javascript">
$(document).ready(function () {
    function handleCheckbox() {
        if ($(this).find(':checkbox').is(':checked')) {
            $(this).find('.file-uploader-attachment-Class').removeClass("upload-placeholder-unchecked");
            createUploader($(this));
        }
        else {
            $(this).find('.file-uploader-attachment-Class').addClass("upload-placeholder-unchecked");
            $(this).find('.file-uploader-attachment-Class').html($('#myHTML2').html());
        }
    }
    $('tr').each(handleCheckbox);
    $('tr').on('click', handleCheckbox);
    function createUploader(container) {
        var elements = container.find('.file-uploader-attachment-Class');
        var CAL_ID = container.find(':checkbox').val()
        var row = $(this).parent();
        Array.prototype.filter.call(elements, function (element) {
            var uploader = new qq.FileUploader({
                element: element,
                sizeLimit: 2147483647, // max size
                action: '/CalibrationViewer/AttachmentUpload',
                allowedExtensions: ['xls', 'xlsx', 'pdf', 'doc', 'docx', 'csv', 'txt', 'rtf', 'zip', 'zipx', '7z'],
                params: {
                    customer: CUST_NAME,
                    calibrationId: CAL_ID
                },
                multiple: false,
                debug: false,
                onComplete: function (id, fileName, responseJson) {
                    alert(responseJson.msg);
                    $('.qq-uploader').remove();
                    elements.closest('.file-uploader-attachment-Class').prepend('<div class="uploadedTag"><p>Uploaded</p></div>')
                }
            });
        });
    }
});

这对

我有用

  elements.closest('.file-uploader-attachment-Class').find('.qq-uploader').remove();