Skip to content

Instantly share code, notes, and snippets.

@justinobney
Created January 21, 2013 13:31
Show Gist options
  • Save justinobney/4586065 to your computer and use it in GitHub Desktop.
Save justinobney/4586065 to your computer and use it in GitHub Desktop.
Patch handlers to log what they are doing..
function patchDelegate(delegate){
console.log("Patching: ", delegate.type, delegate.selector);
var type = delegate.type;
var handler = delegate.handler;
var selector = delegate.selector;
var newHandler = function(e){
e.preventDefault();
console.group();
console.log("Event triggered for: " + selector);
handler(arguments);
console.groupEnd();
}
delegate.handler = newHandler;
}
jQuery.each($._data(document, 'events'), function(i, event){
jQuery.each(event, function(i, delegate){
patchDelegate(delegate);
});
});
var elIds = $("[id]").map(function(i,e){
return e.id
});
var idString = '#' + jQuery.makeArray(elIds).join(',#');
var eventHolders = $('[data-formula="create"]').parents().map(function(i,e){
if($._data(e, 'events')){
return $._data(e, 'events');
}
});
jQuery.each(eventHolders, function(i, eventHolder){
jQuery.each(eventHolder, function(i, event){
jQuery.each(event, function(i, delegate){
patchDelegate(delegate);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment