Created
March 20, 2017 14:28
-
-
Save saade/6b08bed92cba8b4d9fcaa8652d80713b to your computer and use it in GitHub Desktop.
List all Events on current page
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
| // 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