javascript - Blueimp jQuery 文件上传 - 上传完成响应后隐藏队列中的文件

标签 javascript jquery jquery-file-upload blueimp

我正在使用 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);
    }
});

关于javascript - Blueimp jQuery 文件上传 - 上传完成响应后隐藏队列中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24727116/

相关文章:

javascript - jquery.fileupload 插件导致 require.js 随机导入失败

javascript - 如何从 Google Maps JavaScript 地理编码器返回经度和纬度?

javascript - 使用 JavaScript 创建 CSS 样式属性

jquery - 为什么此工具提示遵循相反的垂直方向?

javascript - 如何一次提交两个表单

javascript - 带有 express.js 的 jquery-file-upload-middleware : how to move files & add watermarks?

jQuery 文件上传插件不起作用

javascript - Node mssql 插入返回未定义的记录集

javascript - react JS : Use environment variables to specify two API urls based on production vs development

javascript - 可水平拖动/移动 <div>