Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This plugin hooks into an existing jQuery function and calls a user defined function after a jQuery function was called.
/*
* 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
You can’t perform that action at this time.