Is there a way in jQuery to know if an element already has an event bound to the click or doubleclick?
+2
A:
Maybe this will help:
From here: http://james.padolsey.com/javascript/things-you-may-not-know-about-jquery/
You can access all event handlers bound to an element (or any object) through jQuery’s event storage:
// List bound events:
console.dir( jQuery('#elem').data('events') );
// Log ALL handlers for ALL events:
jQuery.each($('#elem').data('events'), function(i, event){
jQuery.each(event, function(i, handler){
console.log( handler.toString() );
});
});
Aseem Gautam
2010-04-05 12:52:49
yes. ...although it's not documented as officially part of the jQuery interface, so it may not be wise to rely on in an app you expect to run with a future version. Great for testing though.
bobince
2010-04-05 14:49:28