4

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 ?

Xtian
  • 3,535
  • 11
  • 55
  • 91

7 Answers7

5

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();
        });
    }
}
yoku2010
  • 600
  • 1
  • 4
  • 14
2

jqueryUi tooltip has problem with ipad , tool-tip does not disappear if we click anywhere on the page so this simple solution worked for me and working on ios 6 , ios 7 , ios 8 devices

 $("#selector ").tooltip( "close" );

you can use these method

Ranjeet
  • 7,722
  • 1
  • 13
  • 17
1

I was having this same problem and as I see there's not a valid solution here, the correct answer to the question posed above is to use the JQuery tools api to obtain the correct tooltip element and remove it before removing the owner of the tooltip.

var t = $('#object_to_remove').data('tooltip');
if(t) t = t.getTip();
if(t) t.remove();
$('#object_to_remove').remove();

The if(t) pieces are necessary so that this won't error if a tooltip either isn't attached or hasn't yet been called.

Since they are lazily added to the DOM t.getTip may return undefined (this means the tooltip data is still residing in the title attribute and so there is no cleanup to do since it will be removed with the owning DOM element).

Brad Dwyer
  • 6,305
  • 8
  • 48
  • 68
1

I think the cleanest way is to call this command:

$("#your-element").tooltip('destroy');

In short, it removes your current tooltip functionality and #your-element comes back to normal state.

This is a official document: https://api.jqueryui.com/tooltip/#method-destroy

Hoang Le
  • 1,341
  • 14
  • 14
1

remove the tooltip element along with the link.

$('.remove-player-large a').click(function() {
  $('.tooltip').remove();//remove the tool tip element
});

if you don't know the class name of the tooltip element, you will need to use firebug to inspect, or you can find it in the tooltip source code

angry kiwi
  • 10,730
  • 26
  • 115
  • 161
  • 2
    I know this is an old question but I found it in a Google search. This will not work because it will remove tooltips of all other elements on the page as well. – Brad Dwyer Apr 22 '12 at 04:11
0

The somewhat related issue of jqueryui tooltips and iPads is answered elegantly here

Mat K. Witts
  • 163
  • 7
0

Just before you remove the person, send it the .mouseout() event. That will trigger the tooltip's normal mouseout behavior and should hide the tooltip (if it truly goes away on mouseout)

cdeszaq
  • 30,869
  • 25
  • 117
  • 173