如何使用Blueimp jQuery文件上载取消单个文件的上载

如何使用Blueimp jQuery文件上载取消单个文件的上载,jquery,file-upload,blueimp,Jquery,File Upload,Blueimp,我正在使用,它的工作正常,但我有一个问题,取消上传的文件之一 当我添加一个文件时,我会在html中附加一个字段集,其中包含一些额外的输入和一个按钮-取消。我需要的是这样的东西: $(".cancelUpload").on("click", function(){ //remove this file from the queue, The data and the file will not be uploaded }) 这是我代码的一部分 $('#MappeFile').file

我正在使用,它的工作正常,但我有一个问题,取消上传的文件之一

当我添加一个文件时,我会在html中附加一个字段集,其中包含一些额外的输入和一个按钮-取消。我需要的是这样的东西:

$(".cancelUpload").on("click", function(){
      //remove this file from the queue, The data and the file will not be uploaded
})
这是我代码的一部分

$('#MappeFile').fileupload({
        dataType : 'json',
        autoUpload : false,
        maxNumberOfFiles : undefined,
        maxFileSize : 2000,
        minFileSize : undefined,
        acceptFileTypes : /.+$/i,
        url : "/ajax/UploadFile.php",
        add : function(e, data) {
            $("#fileUploadButton").removeClass("toHide").on("click", function() {
                $('#progress .bar').show();
                if ($.browser.msie && parseInt($.browser.version, 10) < 10) {
                    $('#progress .bar').css({
                        "background" : "url(images/progressbar.gif) no-repeat",
                        "width" : "100%"
                    })
                } else {
                    $('#progress .bar').css({
                        'background-color' : "#2694E8",
                        'width' : '0%'
                    });
                }
                data.formData=$("form").serializeArray();
                data.submit();
                $("#fileUploadButton").off("click").addClass("toHide")

            })
        },
        change : function(e, data) {
            $.each(data.files, function(index, file) {

                filesCount++;
                vOutput = "<fieldset class='FileUploadFieldset'>"
                vOutput += "<legend>" + file.name + "</legend>"
                vOutput += "<label>Dateiname:</label><input type='text' value='"+file.name+"' name='Dateiname"+filesCount+"' size='50' class='UploadDateiName inputMaske'/><input type='text' class='toHide originName' name='originName"+filesCount+"' value='"+file.name+"'/>"
                vOutput += "<label>Dokumentdatum</label><input type='text' name='Datum"+filesCount+"' class='UploadDatum inputMaske'>"
                vOutput += "<label>Berater:</label><select name='Berater"+filesCount+"' class='UploadBeraterSelect inputMaske'></select>"
                vOutput += "<fieldset><legend>Kategorie:</legend><div class='UploadKategorie'></div></fieldset>"
                vOutput += "<fieldset><legend>Bemerkung:</legend><textarea name='Bemerkung"+filesCount+"' class='UploadBemerkung inputMaske'></textarea></fieldset>"
                vOutput += "<input type='button' class='cancelUpload neuButton' value='cancel'/>"
                vOutput += "</fieldset>"
                $("#MappeFilesToUpload").append(vOutput);   
            });
        }
    });
如果您正在使用,您只需要添加一个类cancel,它将自动绑定到cancelHandler

尝试更新此行:

 vOutput += "<input type='button' class='cancelUpload neuButton' value='cancel'/>"

这将重置整个表单,但我只想取消其中一个文件,而不是全部。您尝试过吗?我想每个文件都是在不同的表单上提交的。当我点击“取消”按钮时,页面被刷新了……我不知道为什么
    vOutput += '<div class="cancel"> <button> cancel </button> </div>'
   _initEventHandlers: function () {
        this._super();
        this._on(this.options.filesContainer, {
            'click .start button': this._startHandler,
            'click .cancel button': this._cancelHandler,
            'click .delete button': this._deleteHandler
        });
        this._initButtonBarEventHandlers();
    },

    .
    .
    .

    _cancelHandler: function (e) {
        e.preventDefault();
        var template = $(e.currentTarget).closest('.template-upload'),
            data = template.data('data') || {};
        if (!data.jqXHR) {
            data.errorThrown = 'abort';
            this._trigger('fail', e, data);
        } else {
            data.jqXHR.abort();
        }
    },