开发者

Plupload multiple instances

I'm trying to set up unknown number of plupload instances on page. I need to dynamically add more instances and remove and reset some of them. I have the general idea, but nothing works.

One of my tries is on jsfiddle.

Thank you for all the help.

Code:

var uploaders = new Array();

initUploaders = function(uploaders) {
    console.log("initUploaders()");
    $(".gallery").each(function() {
        var el = $(this);
        var button = el.attr("id") + "_uploader";
        console.log("Init uploader id:" + el.attr("id"));
        var uploader = new plupload.Uploader({
            runtimes: 'gears,html5,flash,silverlight,browserplus',
            browse_button: button,
            max_file_size: '10mb',
            url: 'ModuleGallery/Upload/',
            flash_swf_url: 'http://static.srv42.net/plupload/js/plupload.flash.swf',
            silverlight_xap_url: 'http://static.srv42.net/plupload/js/plupload.silverlight.xap',
            filters: [
                {
                title: "Image files",
                extensions: "jpg,gif,png"}
            ]
        });        

        uploader.bind('FilesAdded', function(up, files) {
            uploader.start();
        });

        uploader.init();    
        galleryUploaders.push(uploader);
    开发者_如何学JAVA};

    initUploaders(uploaders);


The answer was pretty simple in the end. You can instance it normally and just bind to QueueChanged event.

uploader.bind('QueueChanged', function (up, files) {
     uploader.start();
     up.refresh();
});


Try this solution. You can have n number of instances with this:

  • Multiple Instances of Plupload - jSFiddle
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜