Skip to content

Instantly share code, notes, and snippets.

@tempredirect
Created March 4, 2011 14:52
Show Gist options
  • Save tempredirect/854708 to your computer and use it in GitHub Desktop.
Save tempredirect/854708 to your computer and use it in GitHub Desktop.
Hacky plugin to allow removal of the tooltips created by jquery tools tooltip
/**
* hacky plugin to allow removal of the jquery tools tooltip objects.
*
* Doesn't pay any attention to the special event configuration, and will blindly unbind all
* mouse[enter|leave] listeners from the trigger element.
*/
(function($){
var tooltip = $.fn.tooltip,
slice = Array.prototype.slice;
function removeTooltip($elements){
$elements.each(function(){
var $element = $(this),
api = $element.data("tooltip"),
tip = api.getTip(),
trigger = api.getTrigger();
api.hide();
if( tip ){
tip.remove();
}
trigger.unbind('mouseenter mouseleave');
});
}
$.fn.tooltip = function(p){
if( p === 'remove'){
removeTooltip(this);
return this;
} else {
return tooltip.apply(this, slice.call(arguments,0));
}
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment