Jquery Tools Tooltip not going away

Xtian picture Xtian · Apr 14, 2011 · Viewed 14k times · Source

I have a tool tip that will appear over anything with a title:

$("[title!=]:not(IFRAME)").tooltip();

I have a list of people that can be Added or Removed, you click a remove button that is positioned over the person, you click it to swap out that person for another person.

When you go to click the Remove button the Tool tip shows up, because that item has a . But once you swap that person out, the tooltip will not go away.

I am pretty sure the reason is that once that person is removed you don't have a mouseout, so the tooltip never goes away.

I tried this:

$('.remove-player-large a').click(function() {
  $("[title!=]:not(IFRAME)").tooltip().hide();
});

But no luck Any suggestions on how to fix this?

Does this makes sense ?

Answer

yoku2010 picture yoku2010 · Jun 12, 2012

You can hide tooltip using hideTooltip() function.

var $tooltip = null;
$(function(){
    $tooltip = $("input[type='text']").tooltip({
        // place tooltip on the right edge
        position: "center right",
        // a little tweaking of the position
        offset: [-2, 10],
        // use the built-in fadeIn/fadeOut effect
        effect: "fade",
        // custom opacity setting
        opacity: 0.6
    });
    $("#close").click(function(){
        hideTooltip();
    });
});
function hideTooltip()
{
    if($tooltip)
    {
        $tooltip.each(function(index){
            var $this = $(this).data('tooltip');
            if($this.isShown(true))
                $this.hide();
        });
    }
}