Jeff Noel
Jeff Noel

Reputation: 7618

Plupload & jQuery UI : Triggering the upload on dialog's button click

I am trying to trigger the plupload.start() event from a jQuery modal dialog button, but it seems like the plupload object is not recognized, thus giving me the following error:

TypeError: Object #<Object> has no method 'start'

I initialized the plupload object on the dialog's opening event, I can upload files correctly using the original button, but I prefer sending the files and the form in a standard layout (instead having two "upload" buttons, the one for the form and the one for the plupload plugin).

I don't want to trigger the upload right on the FileAdded event either. Anyone has an idea on how to proceed?

Initialization code:

$("#uploader").plupload({
                // General settings
                runtimes : 'flash,html5,html4',
                url : 'pagesPub/update_pub.php',
                max_file_size : '25mb',
                chunk_size : '25mb',
                unique_names : true,

                // Specify what files to browse for
                filters : [
                    {title : "Images", extensions : "jpg,jpeg,gif,png"}
                ],

                // Flash settings
                flash_swf_url : 'js/moxie/plupload.flash.swf',

                // Silverlight settings
                silverlight_xap_url : 'js/moxie/plupload.silverlight.xap',

                FilesAdded : function (up, files) {
                    var fileCount = up.files.length,
                    i = 0,
                    ids = $.map(up.files, function (item) { return item.id; });

                    for (i = 0; i < fileCount; i++) {
                        uploader.removeFile(uploader.getFile(ids[i]));
                    }

                    // Do something with file details
                }

            });

Upvotes: 0

Views: 3812

Answers (1)

Jeff Noel
Jeff Noel

Reputation: 7618

plupload.start() is the wrong way to call the method (since it's a jQuery object).

You must call it this way:

$('#uploader').plupload('start');

Upvotes: 1

Related Questions