Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap's tooltip doesn't disappear after button click & mouseleave

I have a problem with bootstrap's tooltip : When I click on a button, tooltip stays even if is the cursor is outside of the button. I have looked into the manual - Bootstrap's tooltip and if I'm clicking on the buttons, I see the same problem. Is there any solution to fix this? Just tried in latest FF, IE.

like image 318
SilentCry Avatar asked Oct 05 '22 00:10

SilentCry


People also ask

How do I enable tooltip disabled button?

By default, tooltips will not be displayed on disabled elements. However, you can enable this behavior by using the following steps: Add a disabled element like the button element into a div whose display style is set to inline-block . Set the pointer event as none for the disabled element (button) through CSS.

How do I make my tooltip always visible?

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


2 Answers

This is because trigger is not set. The default value for trigger is 'hover focus', thus the tooltip stay visible after a button is clicked, until another button is clicked, because the button is focused.

So all you have to do is to define trigger as 'hover' only. Below the same example you have linked to without persisting tooltips after a button is clicked :

$('[data-toggle="tooltip"]').tooltip({
    trigger : 'hover'
})  

the doc example in a fiddle -> http://jsfiddle.net/vdzvvg6o/

like image 293
davidkonrad Avatar answered Oct 19 '22 10:10

davidkonrad


I know over a year old, but I couldn't get this to work with any examples here. I've had to use the following:

$('[rel="tooltip"]').on('click', function () {
    $(this).tooltip('hide')
})

This also shows the tooltip again upon hover.

like image 81
Nitai Avatar answered Oct 19 '22 10:10

Nitai