How to delay show/hide of bootstrap-tooltips?

JqueryTwitter Bootstrap

Jquery Problem Overview


I am having trouble making that data-delay attribute of twitter bootstrap tooltips work. I am using it like :

Here is how i use it :

<a href="#" data-toggle="tooltip" data-delay="{ show: 5000, hide: 3000}">with delay</a>
<script>
    jQuery('a[data-toggle="tooltip"]').tooltip().click( function(e) {
        e.preventDefault(); 
    });
</script>

but i don't see any delay on show/hide. Any ideas why ?

Jquery Solutions


Solution 1 - Jquery

Finally I got it working with data attribute.

data-delay='{"show":"5000", "hide":"3000"}'

The object must be surrounded by single quotes, keys with double quotes and values with double or none, probably depends on the type. Is the only way that works.

This works for popovers too.

Solution 2 - Jquery

Why can't you do it like this?

$('a').tooltip({
     'delay': { show: 5000, hide: 3000 }
});

Solution 3 - Jquery

I prefer it this way:

$(document).ready(function(){
    $('[data-toggle="tooltip"]').tooltip({'delay': { show: 5000, hide: 3000 }
	});   
});

Solution 4 - Jquery

your answer doesn't work with Bootstrap 3.3.2. This one working well for my version:

data-delay='{"show":5000, "hide":3000}'

Source: https://github.com/twbs/bootstrap/issues/13874

Solution 5 - Jquery

You can use:

<div ... popover-popup-delay="2000" ...>

Solution 6 - Jquery

For use with AngularJS (UI):

<div tooltip="Hello" tooltip-popup-delay="500"></div>

Solution 7 - Jquery

Workaround!

Couldn't get it to work for my info message popover on a modal but used this workaround in my JavaScript:

$('#infoPopover').attr("data-original-title", "Delete Document");
$('#infoPopover').attr("data-content", "Success");
$('#infoPopover').popover('show');
setTimeout(function () { $('#infoPopover').popover('hide') }, 4000);

It works on an empty span...

<span id="infoPopover" data-toggle="popover"></span>

popover shows for a few seconds then hides again.

Image of popover info message on a modal

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSpyrosView Question on Stackoverflow
Solution 1 - JqueryazeósView Answer on Stackoverflow
Solution 2 - JqueryGautam3164View Answer on Stackoverflow
Solution 3 - JqueryRustyView Answer on Stackoverflow
Solution 4 - JqueryPascalView Answer on Stackoverflow
Solution 5 - JquerydevsathishView Answer on Stackoverflow
Solution 6 - JqueryJeffrey RoosendaalView Answer on Stackoverflow
Solution 7 - JqueryDaveyView Answer on Stackoverflow