How to make bootstrap tooltip remain visible till the link is clicked

vikas devde picture vikas devde · Oct 22, 2012 · Viewed 60.6k times · Source

I have a link which I am going to use as notification when a user has some new notification I am going to notify the user by showing a tooltip(twitter bootstrap tooltip). What I want to achieve is, that tooltip should remain visible till the user clicks the link. once the user clicks the link, the tooltip should destroy. this is what I have till now, http://jsfiddle.net/testtracker/QsYPv/

HTML

<p><a href="#" rel="tooltip" data-original-title="you have 2 notifications">Notification</a>.</p>​

JavaScript

$('p a').tooltip({placement: 'bottom'}).tooltip('show');​

What's happening there is, tooltip stays visible till you hover it, and takes its default behaviour (show on hover) once you hover it.

I hope I have given proper info and cleared what I want to do.

Answer

vikas devde picture vikas devde · Oct 24, 2012

Here is the solution http://jsfiddle.net/testtracker/QsYPv/8/

Added the option "trigger"

$('p a').tooltip({placement: 'bottom',trigger: 'manual'}).tooltip('show');

then, with this line

$('p a').on('click',function(){$(this).tooltip('destroy');});

destroy tooltip on click.