Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tooltip remains sometimes on page on element inside sliding div

We are using a bootstrap for one of the project and facing an issue with tooltip plugin provided. Its actually not a bug in bootstrap but an issue is created with the situation we're using it.

We have a sliding slidebar that goes inside content div. And buttons for hiding / showing effect with a tooltip. The sliding effect based on jQuery UI slide.

The issue is:

When we click on hide sidebar button, and at the same time moves mouse out of button hover at the time of slide animation, then some times the tooltip doesn't gets hidden, and stays over there on the page.

This happens also on show sidebar too. And when it happens it looks very bad and buggy.

How can we fix this?

like image 541
Krunal Avatar asked May 11 '12 05:05

Krunal


People also ask

How do I make my tooltip always visible?

Enabling sticky tooltip To make an element display its tooltip permanently, we use its showTooltipOn property. To make tooltip always be shown, set it to "always" .

Can a div have a tooltip?

Basic Tooltip HTML: Use a container element (like <div>) and add the "tooltip" class to it. When the user mouse over this <div>, it will show the tooltip text. The tooltip text is placed inside an inline element (like <span>) with class="tooltiptext" .

Which data attribute places a tooltip to the right of an element?

To create a tooltip, add the data-toggle="tooltip" attribute to an element.

Can tooltips be clickable?

As we mentioned in the preamble, tooltips are completely "mute" to any interactions as to not steal hover events from elements underneath them. Even placing interactive elements, such as links, into content of tooltip will not work.


2 Answers

Answered on bootstrap forum by Richard ( https://github.com/r1ch0)

Just manually hide the tooltip when you click the button, before you trigger the slide animation.


$('#button').on('click', function () {
  $(this).tooltip('hide')
  $('#sidebar').slide() // replace with slide animation
})

Copied from: https://github.com/twitter/bootstrap/issues/3446

Posted here just because someone else can find it.

like image 91
Krunal Avatar answered Nov 06 '22 01:11

Krunal


I used Krunal contribution (+1 btw), that helped a lot me but did not completly solved the issue.
The tooltip disappears when I clic on the button, but comes back and gets stuck again when my mouse hovers it, until I click somewhere else.

So i figured out that the tooltip appears while hovering, and also while focusing an element.
Finally i wrote this :

$('button').on('click', function () {
    $(this).blur()
})

And it works well.
Thanks.

like image 39
Charly Avatar answered Nov 06 '22 02:11

Charly