Skip to content

Instantly share code, notes, and snippets.

@saade
Created March 20, 2017 14:28
Show Gist options
  • Select an option

  • Save saade/6b08bed92cba8b4d9fcaa8652d80713b to your computer and use it in GitHub Desktop.

Select an option

Save saade/6b08bed92cba8b4d9fcaa8652d80713b to your computer and use it in GitHub Desktop.
List all Events on current page
// defining function
(function($) {
$.eventReport = function(selector, root) {
var s = [];
$(selector || '*', root).addBack().each(function() {
var e = $._data(this, 'events');
if(!e) return;
var tagGroup = this.tagName || "document";
if(this.id) tagGroup += '#' + this.id;
if(this.className) tagGroup += '.' + this.className.replace(/ +/g, '.');
var delegates = [];
for(var p in e) {
var r = e[p];
var h = r.length - r.delegateCount;
if(h)
s.push([tagGroup, p + ' handler' + (h > 1 ? 's' : '')]);
if(r.delegateCount) {
for(var q = 0; q < r.length; q++)
if(r[q].selector) s.push([tagGroup + ' delegates', p + ' for ' + r[q].selector]);
}
}
});
return s;
}
$.fn.eventReport = function(selector) {
return $.eventReport(selector, this);
}
})(jQuery);
// calling function
console.table($.eventReport())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment