问题
I have Bootstrap Popovers working fine, but the popover get's appended to body at the bottom of the document, as opposed to just below the triggering element, as it does in the bootstrap documentation: http://twitter.github.com/bootstrap/javascript.html#popovers
Anyone know how to control where a popover is inserted? Or at the very least, get it to append to the triggering elements parent?
Here's what I have:
http://jsfiddle.net/qt34N/4/
<a href="#" class="btn" rel="popover" data-placement="top"
data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
data-original-title="Popover on top">Popover on top</a>
jQuery:
$("a[rel=popover]").popover();
Suggestions?
回答1:
The demo is using a newer version of bootstrap. Update to the latest and it will perform like you want it to.
http://jsfiddle.net/qt34N/10/
jQuery(document).ready(function($) {
$("a[rel=popover]").popover();
});
回答2:
Are you including the tooltip (bootstrap-tooltip.js) as required?
http://twitter.github.com/bootstrap/javascript.html#tooltips
Add small overlays of content, like those on the iPad, to any element for housing secondary information. Hover over the button to trigger the popover. Requires Tooltip to be included.
As far as placement goes, you set it in the options:
$('#example').popover({placement:'top'})
or via data
attribute:
data-placement="top"
来源:https://stackoverflow.com/questions/13369306/twitter-bootstrap-popover-dom-insertion-location