Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to show tooltip when hovering?

I defined my bootstrap tooltip like this:

 <button popover-template="myPopoverTemplate.html" data-trigger="hover" popover-title="{{dynamicPopover.title}}" class="btn btn-default">Popover With Template</button>

my template looks like this:

<div>{{dynamicPopover.content}}</div>
<div class="form-group">
  <label>Popup Title:</label>
  <input type="text" ng-model="dynamicPopover.title" class="form-control">
</div>

Problem is the tooltip does not showup on hover?

plunkr ref:http://plnkr.co/edit/G1Cet74mVCkVYvdXRxnX?p=preview

like image 411
Leeuwtje Avatar asked Jul 10 '15 05:07

Leeuwtje


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

What is tooltip on hover?

Tooltip is a concept used in HTML for showing some extra information about the specifically selected element. This can be done on the mouse hover effect whenever the user moves the mouse over an element that is using a tooltip to display specified information about that element.

Are hover tooltips accessible?

An example of a native browser tooltip is the way some browsers display an element's title attribute on long mouse hover. One cannot activate this feature through either keyboard focus or through touch interaction, making this feature inaccessible.

How do you make a hover pop-up in HTML?

To make a simple tooltip, we'll first create the HTML element that triggers the tooltip when hovered over. We'll create this element as a div and assign it the class hover-text. Next, we'll create the element for the tooltip itself. This will be a span element with the class tooltip-text.


1 Answers

@Leeuwtje, in the plunkr reference that you have attached, there is a popover that is opening on mouseenter event (when you hover the mouse over the button).

The attribute to do that is not data-trigger="hover", but popover-trigger="mouseenter".

Also, for the template popover-template="dynamicPopover.templateUrl" is added as an attribute to the element that triggers it.

Also, if you need to prefix the attributes with data-, do them like this:

<button data-popover-template="" data-popover-trigger="" /></button>

The popover prefixed to -template or -trigger in popover-trigger and popover-template makes it an angular ui directive, so removing popover- would make it invalid / meaningless to angular ui.

EDIT

The reason the popover-template did not work is because it expects a variable as the attribute value.

Replacing :

popover-template="myPopovertemplate.html"

by

popover-template="'myPopovertemplate.html'"

Adding the filename in quotes does the trick.

We put the template url in single quotes so it becomes a valid variable. That is why the other buttons on the page in the plunk function, because they have the popover-template value to be variables that are defined in $scope.

PLUNK : http://plnkr.co/edit/oEA5ekXDV5DSw6yoSHMd?p=preview

Hope this helped!

like image 80
tasty_snack Avatar answered Oct 11 '22 11:10

tasty_snack