Search code examples
javascripttwitter-bootstraptooltip

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


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.


Solution

  • 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.