Twitter Bootstrap Popover - DOM Insertion Location

主宰稳场 提交于 2019-12-11 10:44:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!