其他分享
首页 > 其他分享> > 引导两次内容回调的Bootstrap委托弹出

引导两次内容回调的Bootstrap委托弹出

作者:互联网

我正在使用Twitter Bootstrap 2.3.2,并且我在注册带有弹出式选择器的td时将其打开.但是我在控制台中注意到,内容回调被触发了两次.有办法防止这种情况发生吗?

$('#table-data').popover({
    selector: '.td-popover',
    trigger : 'hover',
    content : function () {
        console.log(this, arguments)
        return 'hello';
    }
});

<table id="table-data">
    <tbody>
        <tr>
            <td></td>
            <td class="td-popover"></td>
            <td></td>
            <td class="td-popover"></td>
        </tr>
    </tbody>
</table>

解决方法:

您的代码是正确的,此问题来自引导程序本身,他们说这是故意的行为,而不是错误.有关更多详细信息,请参见此github问题https://github.com/twbs/bootstrap/issues/12563

仅供参考,他们没有在Bootstrap 3.2(当前的稳定版本)中更改此行为,但我认为他们计划在下一个版本(3.2.1)中进行更改.

标签:twitter-bootstrap,delegates,events,javascript
来源: https://codeday.me/bug/20191121/2052790.html