Twitter bootstrap popover在打开new时关闭 [英] Twitter bootstrap popovers close when opening new

查看:94
本文介绍了Twitter bootstrap popover在打开new时关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是JavaScript向导,所以我很遗憾这里显而易见的东西。我有一个使用 Twitter Bootstrap的弹出行为的多个链接的表 。我有它点击一个链接打开弹出窗口,然后点击另一个关闭第一个,但它几次尝试后变得有毛病,甚至开始关闭自己。所以问题是:一旦打开另一个弹出窗口,你如何正确地关闭弹出窗口?

I'm not JavaScript wizard, so I'm missing something obvious here I'm sure. I have a table that has multiple links utilizing Twitter Bootstrap's pop-over behavior. I have it where clicking on a link opens the pop-over, and clicking another closes the first, but it becomes glitchy after a few tries, and even starts to close itself. So the question is: How do you properly make pop-overs close once another is opened?

我在这里建立了一个JSFiddle(虽然它似乎根本没有工作): http://jsfiddle.net/ZnJ6b/

I set up a JSFiddle here (although it doesn't seem to be working at all): http://jsfiddle.net/ZnJ6b/

HTML:

<table>
    <thead>
        <th>Description</th>
        <th>Button</th>
    </thead>
    <tbody>
        <tr>
            <td>Item #1</td>
            <td><a href="#" class="btn show-text" data-toggle="popover" data-placement="right" data-content="Content for item one." title="" data-original-title="Review text">Click for text</a>

            </td>
        </tr>
        <tr>
            <td>Item #2</td>
            <td><a href="#" class="btn show-text" data-toggle="popover" data-placement="right" data-content="Content for item two." title="" data-original-title="Review text">Click for text</a>

            </td>
        </tr>
    </tbody>
</table>

Javascript:

Javascript:

$(this).popover('show');
$('.show-text').click(function () {
    $('.show-text').popover('hide');
});

提前感谢您对可怜的JS n00b的帮助!

推荐答案

试试这个:

$('.show-text').popover();
$('.show-text').click(function () {
     $('.show-text').not(this).popover('hide');
});

这篇关于Twitter bootstrap popover在打开new时关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆