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?
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.
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.
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.
You can also check using a condition $('#anElement'). next(). hasClass('popover') which will return true if the popover is on.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With