Created
May 29, 2013 11:24
-
-
Save davidhellsing/5669606 to your computer and use it in GitHub Desktop.
Detect possibly conflicting or multi-bound events in jQuery
This file contains 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($) { | |
var add = $.event.add; | |
$.event.add = function() { | |
var elem = arguments[0], | |
types = arguments[1]; | |
if ( !types || !elem ) return add.apply(this, arguments); | |
types = (types || "").match(/\S+/g) || []; | |
var events = $._data(elem).events; | |
if ( events && types.length ) { | |
$.each(types, function(i, type) { | |
if ( type in events ) console.warn('Multiple event type "'+type+'" detected.', elem, events[type]); | |
}); | |
} | |
return add.apply(this, arguments); | |
}; | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment