最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Twitter Bootstrap, show all popovers at one div - Stack Overflow

programmeradmin0浏览0评论

I tried to achieve the following using Twitter Bootstrap 2.0 and it's popover-plugin, but after a few hours, I still can't figure it out.

Let's just say, on the down-left corner of my page I got a picture showing a bird. This bird should "speak" every popover, for example the ones for a registration form, should appear on top of the bird. Is this possible?

For better understanding I created a test site over here. If you hover over the registration fields, there are the popovers. I want them to appear over the bird-img in the down-left corner, but I don't know how to achieve this. It would be great if you could help me.

I tried to achieve the following using Twitter Bootstrap 2.0 and it's popover-plugin, but after a few hours, I still can't figure it out.

Let's just say, on the down-left corner of my page I got a picture showing a bird. This bird should "speak" every popover, for example the ones for a registration form, should appear on top of the bird. Is this possible?

For better understanding I created a test site over here. If you hover over the registration fields, there are the popovers. I want them to appear over the bird-img in the down-left corner, but I don't know how to achieve this. It would be great if you could help me.

Share Improve this question edited Jun 23, 2012 at 17:21 Andrew Marshall 97k20 gold badges227 silver badges217 bronze badges asked Jun 23, 2012 at 17:19 DominikDominik 2,9062 gold badges36 silver badges47 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Method 1:

The jQuery hover handler takes an "in" and an "out" method, and in your sample you are only assigning the "in" method, to show the popup. This is fine, but rather than attach it to "this", you should attach it to your bird image. Make sure to change the trigger of the popup to manual also. Then in the "out" method of hover, you just need to hide the popover.

$('#registerHere input').hover(function()
{
    $('#birdie').popover({
            "trigger": 'manual',
            "placement":'top',
                }).popover('show');
},
function()
{
    $('#birdie').popover('hide');
});

Method 2:

Alternately, keep what you have, but use the "selector" option provided, and give it your bird image as a parameter, this should trigger the popover from your control, but delegate it to your bird image.

selector: if a selector is provided, tooltip objects will be delegated to the specified targets

$('#registerHere input').hover(function()
{
    $('#birdie').popover({
            "selector": "#birdie",
            "placement":'top',
                }).popover('show');
});

EDIT: Added sample code. I don't have a chance to test this, so there might be some syntax error or something, but the general idea is there.

发布评论

评论列表(0)

  1. 暂无评论