jQuery文件上传-上传完成后从队列中隐藏文件

Blueimp jQuery File Upload - hide file from queue after upload done responce

本文关键字:队列 隐藏文件 文件 jQuery      更新时间:2023-09-26

我使用的是Blueimp jQuery文件上传插件,我的配置是:

$('#fileupload').fileupload({
    // Uncomment the following to send cross-domain cookies:
    //xhrFields: {withCredentials: true},                
    url: 'assets/plugins/jquery-file-upload/server/php/',
    done: function (e, data) {
        //some code
    }
});

当一个文件上传完成后,我需要在done:事件列表中隐藏该文件,但我无法在队列列表中获得该文件的索引。

任何想法?

找到解决我问题的方法了

jQuery Fileupload返回done事件的数据,其中包含每个上传线程的context参数,这与DOM元素相关,可用于任何操作,如隐藏在我的情况下:

 $('#fileupload').fileupload({
    // Uncomment the following to send cross-domain cookies:
    //xhrFields: {withCredentials: true},                
    url: 'assets/plugins/jquery-file-upload/server/php/',
    done: function(e, data) {
        //hide completed upload element in queue
        $(data.context['0']).fadeOut(700);
        //here isoutput of uploaded objects
        console.log(data.result);
    }
});