Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Bootstrap 3 popovers use an external div for content?

All of the examples here http://getbootstrap.com/javascript/#popovers use inline content for the popovers with the data-content attribute.

What I'd like to do is set up a hidden div on my page with the content, and target that from the popover trigger, like:

<div id="myPopoverContent">
   ...stuff...
</div>

and then

<a ng-href="" data-toggle="popover"><span class="badge">12</span> You have 12 messages.</a>

as the trigger. But how to trigger?

like image 540
Steve Avatar asked Apr 24 '14 15:04

Steve


People also ask

How do you use bootstrap Popovers?

To create a popover, add the data-toggle="popover" attribute to an element. Note: Popovers must be initialized with jQuery: select the specified element and call the popover() method.

How do I customize bootstrap popover?

To create a popover, you need to add the data-bs-toggle="popover" attribute to an element. Whereas, popover's title and its content that would display upon trigger or activation can be specified using the title and data-bs-content attribute respectively. Here is the standard markup for adding a popover to a button.

How does bootstrap define popover?

A Bootstrap Popover is an attribute in bootstrap that can be used to make any website look more dynamic. Popovers are generally used to display additional information about any element and are displayed with a click of a mouse pointer over that element.

How do I know if my popover is visible or not?

You can also check using a condition $('#anElement'). next(). hasClass('popover') which will return true if the popover is on.


1 Answers

Use the content option of the popover function to pass the content:

{
    content: $('#myPopoverContent').text()
}

To be able to use HTML content, use:

{
    content: $('#myPopoverContent').html(),
    html: true
}

I’ve prepared a working example for you.

like image 135
Raphael Schweikert Avatar answered Oct 14 '22 07:10

Raphael Schweikert