Plupload jQuery UI小部件并刷新队列



好吧,我已经创建了一些测试代码来尝试清除上传队列,但我只是不知道如何从我所在的位置访问refresh()函数。我使用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();

您可能还想查看其他可用的事件,因为我怀疑您应该在FilesAdded而不是QueueChanged上进行检查,但这取决于您试图实现的目标。

$.getJSON(CI.base_url + 'private/ad_ajax/count_uploaded_images/', function(data) {
if(data.message != "go") {
    alert("Maximum photo uploads reached.");
    do_continue = false;
    plupload.each(files, function(file) {
        up.removeFile(file);
    });
}
});

是不是答案-up.refresh()等由于某种原因不起作用。

最新更新