test if event handler is bound to an element in jQuery
Killing off the binding when it does not exist yet is not the best solution but seems effective enough! The second time you ‘click’ you can know with certainty that it will not create a duplicate binding.
I therefore use die() or unbind() like this:
$("#someid").die("click").live("click",function(){...
or
$("#someid").unbind("click").bind("click",function(){...
or in recent jQuery versions:
$("#someid").off("click").on("click",function(){...
You can get this information from the data cache.
For example, log them to the console (firebug, ie8):
console.dir( $('#someElementId').data('events') );
or iterate them:
jQuery.each($('#someElementId').data('events'), function(i, event){
jQuery.each(event, function(i, handler){
console.log( handler.toString() );
});
});
Another way is you can use the following bookmarklet but obviously this does not help at runtime.