Allow to pass in objects instead of just element IDs #283

wants to merge 3 commits into


None yet
7 participants

I changed all references of document.getElementById(someID) to be a function I wrote, called getElement:
function getElement(element){
return typeof(element) == "object" ? element : document.getElementById(element);

It makes it a lot easier to have plupload on multiple forms on the same page... Let me know if you have any questions...

It looks like some of this needs to be refactored, as a dom node + '_html5' obviously won't work.


omricohen replied Sep 6, 2011

*dom node id, this actually works ;)


gonchuki commented Jan 13, 2012

Interesting, I just did this same patch on my codebase yesterday.
I would suggest using element instanceof Element instead of accepting arbitrary objects (a jQuery object wouldn't work there, for example). This is so that if you pass any arbitrary object, the code that dies is on document.getElementById instead of a random plupload utility function that is trying to work on what it thinks is a DOM element (easier debugging, peace of mind)

edit: the above was a bad suggestion, IE7 doesn't have a native Element.

Any updates on the state of this? I need to use plupload in conjunction with backbone so I can't really rely on passing only an id for the browse button since the rendered template might not be in the DOM when I initialize the uploader

I just forked the repo and cherry-picked the required changes so that it is up to date with the master branch of plupload.

@moxiecode Let me know if that would better suit you in order to fix this issue ; if so I,ll simply initiate another pull request

sontek commented Feb 20, 2012

I also need this, I just e-mailed support and created a ticket about this before I found this ticket.

@glesperance have you maintained an up to date fork of plupload?

sontek commented Feb 20, 2012

I tried doing the following with your branch and it didn't seem to try to render at all:

                    var container = $(el).find("#uploader");

                    var uploader = new plupload.Uploader({
                        // General settings
                        runtimes : 'html4, html5', 
                        url : '/api/files/',
                        max_file_size : '1000mb',
                        container : container[0],
                        max_file_count: 20, // user can add no more then 20 files at a time
                        chunk_size : '1mb',
                        unique_names : true,
                        multiple_queues : true,
                        headers: {'X-EventQ-Key': EventQ.get_api_key()},

                        // Resize images on clientside if we can
                        resize : {width : 320, height : 240, 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"},
                            {title : "Zip files", extensions : "zip,avi"}

sontek commented Feb 20, 2012

I got the container working but can't get the add files button to work

@sontek I got the browse button working on my version using

 browse_button   : this.$('.image-upload-button')[0]

(I'm using backbone too). Maybe if you posted your updated configuration that would help diagnose the problem.

Would this commit make it possible to have multiple browse buttons that add files to the same uploader instance?

@jayarjo jayarjo added a commit that referenced this pull request Feb 24, 2013

@jayarjo jayarjo Underline the fact that DOM elements can now be used directly for bro…
…wse_button and drop_element options. Address #55, #283, #440, #453, #494.

jayarjo closed this Feb 24, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment