Skip to content

Instantly share code, notes, and snippets.

@dragouf
Created August 17, 2015 11:47
Show Gist options
  • Save dragouf/4c1e0c8fcbc911910beb to your computer and use it in GitHub Desktop.
Save dragouf/4c1e0c8fcbc911910beb to your computer and use it in GitHub Desktop.
List jQuery events
function listEvents(name) {
var cache = jQuery.cache,
exp = jQuery.expando,
key, cacheObj, events, event, namespace, handlers = [],
eventsObjects, eventObject, i, l;
for (key in cache) {
cacheObj = cache[key];
if ("events" in cacheObj) {
events = cacheObj.events;
for (event in events) {
eventObjects = events[event]
l = eventObjects.length;
for (i = 0; i < l; ++i) {
eventObject = eventObjects[i];
eventName = eventObject.type;
//console.log(eventObject);
if (eventName === name) {
handlers.push({
handler: eventObject.handler,
elem: cacheObj.handle.elem,
eventObj: eventObject
});
}
}
}
}
}
return handlers;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment