Last active
August 29, 2015 14:01
-
-
Save THEtheChad/4f14ddaa7b7a7884dd61 to your computer and use it in GitHub Desktop.
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
// Store a copy of the original jQuery#removeClass method | |
var _originalMethod = $.prototype.removeClass; | |
// Replace the jQuery#removeClass method with our own | |
// custom function | |
$.prototype.removeClass = function(){ | |
// Convert the arguments object into an array | |
var args = Array.prototype.slice.call(arguments); | |
// Call the original jQuery#removeClass method | |
// and pass it the current context and arguments. | |
// Record the response as well. | |
var response = _originalMethod.apply(this, args); | |
// Trigger our hook and pass it the current | |
// context and arguments | |
$(document).trigger('removeClass', { | |
context: this, | |
args: args | |
}); | |
// Return the response from the original function | |
return response; | |
}; |
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
$(document).on('removeClass', function(evt, obj){ | |
// obj.context is the element (or list of elements) who's class was removed | |
// obj.args are the original arguments passed to the jQuery#removeClass method | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment