New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to reference the source element when using multiple instances? #25
Comments
Re the bit about how I changed the event callbacks, I have rolled that back, events are working with the vanilla version of jquery-filedrop.js, but still the way that I am attempting to use multiple instances is not working for me. |
Having the same problem here. Seems to me like opts gets overwritten with every .filedrop() call.. |
Like nphase said, opts gets overwritten each time you call .filedrop(). Here is a quick fix: https://gist.github.com/1384760 It's not the correct way to do it...I've just moved all the functions accessing opts inside the scope of .filedrop(). It's not very memory efficient, a real object oriented approach, or attaching opts to the corrosponding element using e.g. $.data probably be better? Works ok if you just need two different drop targets though... |
I have this same problem as well. Didn't notice it until I had already started using this plugin in a production system. I've submitted a pull request based on rewrite much like the gist of hansent. It just makes opts private to each instance of filedrop and also makes the helper functions private as well. I guess if you put a bunch of instances on a single page you could end up bloating memory, but that wasn't a concern for my system. |
fixes issue #25 - multiple instances of filedrop
hqmq fixed this in #40 thank you. |
Hi!
Great plugin - I had a lot of trouble getting others to work nicely without an existing form, this one seems to handle that really well.
I want to have several "drop targets" on my page, and the upload script (and uploadFinished handler) will do specific things dependent on which element the file was dropped on. I'm trying to use the data option to send the element name to the upload script. This seems to work (upload script sees the element name) but in every case, the element name that is sent is the last one that was defined, not the one that the file was dropped on. Eg:
Here I'm passing the data as "blockname" which I set earlier (since $(this) appears... broken) but no matter which div I drop a file onto, the "source" paramater is set to "dropdiv4".
I'm testing on Chrome 14. I did make another change to the events (I made it call xhr.onreadystatechange instead of onload - the latter appears non-functional in chrome14? At any rate, I don't think it will affect this)
I figure I am doing something silly with the .each call or more general-boneheadedness :-) What am I missing here?
The text was updated successfully, but these errors were encountered: