Created
January 21, 2013 13:31
-
-
Save justinobney/4586065 to your computer and use it in GitHub Desktop.
Patch handlers to log what they are doing..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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