好吧,我一直在创建一些测试代码来尝试清除上传队列,但我只是不知道如何从我所在的位置访问刷新()函数。我使用 jQuery UI 小部件作为工作基础。 我使用 INIT 的部分让我很痛苦,我似乎无法弄清楚如何从 json 调用中刷新()。我希望你能启发我,因为显然我对 jQuery 很烂。
var do_continue = false;
$("#uploader").plupload({
// General settings
runtimes : 'html5,browserplus,silverlight,gears,html4',
url : CI.base_url + 'private/ad/upload_ad_images',
max_file_size : '2mb',
max_file_count: 5, // user can add no more then 20 files at a time
//chunk_size : '1mb',
unique_names : true,
multiple_queues : true,
// Resize images on clientside if we can
//resize : {width : 800, height : 600, quality : 90},
// Rename files by clicking on their titles
rename: true,
// Sort files
sortable: true,
// Specify what files to browse for
filters : [
{title : "Image files", extensions : "jpg,gif,png"}
],
// Flash settings
flash_swf_url : CI.base_url + 'scripts/plupload/js/plupload.flash.swf',
// Silverlight settings
silverlight_xap_url : CI.base_url + 'scripts/plupload/js/plupload.silverlight.xap',
// Post init events, bound after the internal events
init : {
QueueChanged: function(up) {
// check for max photos here
$.getJSON(CI.base_url + 'private/ad_ajax/count_uploaded_images/', function(data) {
if (!data.message) {
alert("no data found? - please contact us with this message.");
do_continue = false;
}else if(data.message != "go") {
alert("Maximum photo uploads reached.");
do_continue = false;
}
if (!do_continue) {
$(this).refresh(); // -->> need something that works here
}
});
}
}
});
最佳答案
您到底想在 UI 中刷新什么?据我所知,refresh() 只会在运行时的正确位置重新绘制 plupload 透明垫片。它不会重新加载整个 UI 或刷新/清除上传队列。
如果您能详细说明一下您尝试刷新的内容/原因,我也许可以为您提供进一步的帮助。无论哪种方式,都会根据您的代码调用刷新,如下所示:
up.refresh();
如果您尝试完全清空上传队列,请按如下方式完成:
up.splice();
或者从代码中的其他任何地方使用:
var uploader = $('#uploader').plupload('getUploader');
uploader.splice();
您可能还想查看其他可用的 events因为我怀疑您应该检查 FilesAdded 而不是 QueueChanged,但这取决于您想要实现的目标。
关于jquery - Plupload jQuery UI 小部件并刷新队列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8826466/