Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a tooltip to appear in a popover?

On my machine, this code produces a tooltip on hover over a bootstrap glyphicon:

<span class="glyphicon glyphicon-info-sign tt" data-toggle="tooltip" data-placement="top" title="" data-original-title="Tooltip on top"> </span> 

However when I stack the tooltip inside a popover, the code used to generate a tooltip on its own no longer produces a tooltip:

<a href="#" class="example" data-toggle="popover" >Experiment</a>
<div id="popover_content_wrapper" style="display: none">
  <a href=""> 
    <span class="glyphicon glyphicon-info-sign tt" data-toggle="tooltip" data-placement="top" title="" data-original-title="Tooltip on top"> </span>
  </a>
</div>

Here's how I'm triggering the popover and tooltip in the javascript (below these html elements)

<script>
    $('.tt').tooltip();
    $('.example').popover({
        trigger: 'hover click', 
        html: true,
        content: function() {
            return $('#popover_content_wrapper').html();
        }, 
        placement: 'top', 
        delay: { show: 500, hide: 1000 }
    });

</script>

Any ideas on how to get a tooltip to appear on an element inside a popover?

like image 579
minda Avatar asked Oct 18 '13 00:10

minda


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

How do I display tooltips?

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

Can you use tooltips and popovers inside a modal component?

Tooltips, popovers and modal windows are great for clarifying certain words or showing additional information in context without having too much text or taking up too much screen space at once. You can use tooltips, popovers and modal windows in surveys and ReportBuilder elements.

How do you make a popover hover?

Set the trigger option of the popover to hover instead of click, which is the default one. Or with an initialization option: $("#popover"). popover({ trigger: "hover" });


1 Answers

The problem is that the .tt classed element that appears in your popover is not the same one used to bind .tooltip() to.

You need to use the delegation model via the selector option, eg

$(document).tooltip({
    selector: '.tt'
});

Demo here - http://jsfiddle.net/jAtqW/

like image 147
Phil Avatar answered Oct 10 '22 15:10

Phil