Here is a function I created to get the click event from a DOM element.
You need to supply the id to the function and it returns the click event function as a javascript
function that can be stored in a variable for later use.
Usage example
var clickEvent = getClickEvent('elementID'); // stores the element's click event function to clickEvent
$('#elementID').unbind(); // unbinds the events from the element
$('#elementID').click(clickEvent); // sets the click event for the element to the previous state
// Give element ID, returns click event as a javascript object
function getClickEvent(id){
var theEvent;
jQuery.each($('#' + id).data('events'), function(i, event){
if(i = 'click'){
jQuery.each(event, function(i, handler){
theEvent = handler;
});
}
});
return theEvent;
}