0

我无法让 Bootstrap 3.3.5 弹出框工作。我希望在悬停输入组插件时弹出框变得可见,但没有任何反应。

我当前的代码:

Javascript:

    $(document).ready(function () {
        $("[data-toggle=popover]").popover({ trigger: 'hover', container: '#imgPopover'});
    });

HTML

<div class="input-group">
    <button id="imgPopover" type="button" class="input-group-addon"  data-toggle="popover" data-placement="bottom" data-content="Content" data-trigger="hover">
        <img src="~/images/absolent-logo.gif" style="max-height: 20px" />
        <span data-bind="html: $parents[1].text.qTempHeader"></span>
    </button>
    <input type="number" class="form-control" data-bind="value: qTemp"/>
</div>

我尝试了很多不同的东西,但似乎没有任何效果。朝着正确的方向推动将不胜感激。

4

1 回答 1

1

问题出在container: '#imgPopover'属性上,div 太小而无法包含弹出框。将其更改为body及其工作。

    $(document).ready(function () {
        $("[data-toggle=popover]").popover({ trigger: 'hover', container: 'body'});
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>

<div class="input-group">
    <button id="imgPopover" type="button" class="input-group-addon"  data-toggle="popover" data-placement="bottom" data-content="Content" data-trigger="hover">
        test me
    </button>
    
</div>

于 2016-04-04T13:04:27.367 回答