I'm trying to create a custom callback for the jQuery .animate() function. I'm limited to jQuery 1.4.2 and based my custom call on this [article by Dan Switzer][1]
(function ($){
var oldAnimate = $.fn.animate;
$.fn.animate = function(){
this.trigger('animate.before', arguments);
var animateResult = oldAnimate.apply(this, arguments);
this.trigger('animate.after', arguments);
return animateResult;
};
})(jQuery || {});
$('#ID').bind('animate.after', function (){
//Do Something
});
However when I run this code, my '//Do Something' does not trigger. I also tried following [Dave Ward's article][1] as well, using this:
var oldAnimate = jQuery.animate;
jQuery.animate = function() {
if (typeof animate.before === 'function')
animate.before.apply(this, arguments);
var animateResult = oldAnimate.apply(this, arguments);
if (typeof animate.after === 'function')
animate.after.apply(this, arguments);
return animateResult;
};
I'm not sure where I'm going wrong.