Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the "live" feature of bootstrap's popovers?

In the old days, bootstrap's popover had a "live" option which allowed us to make the $('.myclass').popover({live: true}) call even before the DOM elements existed. I looked at the docs for 2.2 and this seems to be gone. What's the new way to do it?

like image 362
Paul Biggar Avatar asked Nov 04 '12 05:11

Paul Biggar


People also ask

How do you trigger a popover manually?

Default title value if title attribute isn't present. If a function is given, it will be called with its this reference set to the element that the popover is attached to. How popover is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space.

How do I show popover on hover?

To make the image on hover in popover just insert an image as an HTML element to the data-mdb-content and set the data-mdb-html to true .

How do I use bootstrap popover?

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.

Which attribute is used to store the popover content?

The data-toggle attribute defines the Popover, the title attribute defines the Tile for the Popover and the data-content attribute is used to store the content to be displayed in the respective Popover.


1 Answers

The live mode is not used any more.

The Bootstrap JS plugins now use delegated events via the jQuery .on method. You can supply an event delegation target selector pointing to an element which might or might not exist.

$('.some-container').popover({
  selector: '.has-popover'
});

Working example generating DOM elements with popover attached: http://jsfiddle.net/asKF9/

like image 178
Gregor Avatar answered Sep 29 '22 07:09

Gregor