0

I can't get Bootstrap 3.3.5 popover to work. I want the popover to become visible when hovering the input-group-addon, but nothing happens.

My current code:

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>

I've tried a bunch of different things, but nothing seems to do it. A push in the right direction would be much appreciated.

robbannn
  • 5,001
  • 1
  • 32
  • 47
  • try this $('body').popover({selector:'[data-toggle="popover"]'}); – Satya Apr 04 '16 at 12:58
  • I have found a tutorial on W3Schools: http://www.w3schools.com/bootstrap/bootstrap_popover.asp just scroll a bit down and see the last example :) – node_modules Apr 04 '16 at 13:00

1 Answers1

1

the problem is with the container: '#imgPopover' attribute, the div is too small to contain the popover. change it to body and its working.

    $(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>
Zamboney
  • 2,002
  • 12
  • 22