admin管理员组

文章数量:1302268

I'm trying to get a popover to be inserted into a specific element, since at the moment, the popover is being insert straight into <body> (and I need it relative to some other elements). However, I can't seem to find how to get the popover to be inserted into a certain element? How can I trigger this?

Edit: I have found that using "inside" in the placement options will insert it into the element that triggered it. This is close, but I need a way to insert it a bit higher up in the DOM.

I'm trying to get a popover to be inserted into a specific element, since at the moment, the popover is being insert straight into <body> (and I need it relative to some other elements). However, I can't seem to find how to get the popover to be inserted into a certain element? How can I trigger this?

Edit: I have found that using "inside" in the placement options will insert it into the element that triggered it. This is close, but I need a way to insert it a bit higher up in the DOM.

Share edited Nov 9, 2012 at 22:29 Brian asked Nov 9, 2012 at 22:03 BrianBrian 2,8294 gold badges25 silver badges30 bronze badges 4
  • Have you mingled with the selector possibility? – davidkonrad Commented Nov 10, 2012 at 0:19
  • Yes. That's a strange property which has more to do with setting triggers that might not exist in DOM/created through Javascript, it really has no use in this case. – Brian Commented Nov 10, 2012 at 2:41
  • using 'inside' in the placement option does not work for me at all. It gives a jQuery error. Can you show me how you did it? I don't understand Yohn's answer below. There's got to be a way to control where the popover is placed in the DOM, as on their own example page, the popovers are placed as the next sibling to the calling element... – chuuke Commented Nov 13, 2012 at 21:18
  • It's supposedly a work in progress feature (hence why it's not even documented). I am using the latest Bootstrap & Jquery, if that's any use. Also remember to set position: relative to the parent, since popover is absolute. Yohn's answer modifies the ponent's JS to add the feature, since there is no native option to chance its specific spot in DOM. – Brian Commented Nov 14, 2012 at 15:15
Add a ment  | 

2 Answers 2

Reset to default 5

You can update your tooltip.js to this file - my tooltip.js and then select the the element you want to the popover to be appened to by either adding data-container=".element" or with javascript

$(element).popover({ container: '.popover-holder' })

another script for bootstrap partent hover option

https://github./sja87/bootstrap-tooltip-parent

本文标签: javascriptBootstrap Popover parentStack Overflow