Necessity is the mother of invention, and 9 times out of 10, when it comes to web development, someone has most likely had the same problem you are having. Thank goodness that you are working in the best environment to find the answer to your problem, the “interwebs”.
I found this post on stack overflow which details how to loop through listeners on a particular element. I tried this, but couldn’t get any good details out of the events. I couldn’t distinguish between the exact event I wanted to work with, and other events that where already bound to the element that I would not want to effect. The second answer to the question pointed to a jQuery plugin called hasEventListener written by sebastienp. This plugin provides multiple ways to check different elements for events, including namespaced events. Sweet!!
The only problem was that sebastien has written it to work with jQuery 1.4.3+, and I was running 1.4.2. I probably could have tired to upgrade, but I am currently using jQuery tools heavily in my app, and it has not be updated to work with jQuery 1.4.3 yet (at least their download page shows that it is not). I tried using the plugin anyway, and it blew up on me.
I have never written a jQuery plugin of my own (I obviously should), and only fixed trivial things in other plugins. When I looked at this plugin, there was nothing that stood out to me as to what was causing the issue. So I took a shot in the dark and sent sebastien a message via twitter asking if there was any way to get it working with an earlier version on jQuery. After waiting a little while, I reverted back to the old unbind/bind trick and went to bed. I don’t expect my issues to become someone else’s.
To my surprise, when I woke up the next morning, not only had sebastien responded but he had updated the plugin to work with jQuery 1.2.3+ (not sure if someone else needed it for an earlier version, or he just checked it on earlier versions). He lives in France and said he was sleeping when I first messaged him. I was floored. After a few more correspondence via twitter I got the plugin working correctly and I could know that my app was going to be working much more efficiently. Instead of always unbind and binding the handler, I just check to see if it’s there, and only bind if I need to.
I know I title this post “collaboration”, but I didn’t really do anything but notify sebatien that I needed help, but I wanted to stress his end of collaborating to help me solve my problem. I hope to return the favor to him or someone else someday soon.