Created
August 20, 2012 08:16
-
-
Save visiongeist/3402141 to your computer and use it in GitHub Desktop.
This plugin hooks into an existing jQuery function and calls a user defined function after a jQuery function was called.
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 hook jQuery plugin | |
* version 1.0 | |
* author: Damien Antipa | |
* http://github.com/dantipa/ | |
*/ | |
(function(window, $, undefined){ | |
/** | |
* Hooks into a given method | |
* | |
* @param method | |
* @param fn | |
*/ | |
$.fn.hook = function (method, fn) { | |
var def = $.fn[method]; | |
if (def) { | |
$.fn[method] = function() { | |
var r = def.apply(this, arguments); //original method | |
fn(this, method, arguments); //injected method | |
return r; | |
} | |
} | |
} | |
})(window, jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment