AgainMe
AgainMe

Reputation: 780

Bootstrap popover doesn't appear the first time

I have some problem with bootstrap popover, in particular it appear only the second time that I hover the mouse on it. The first time nothing is displayed, I don't understand why. This is my code:

 <div id="popover-content" class='popup' rel='popover'>hover me</div>

this is the js:

$(document).ready(function()
{
    $('body').on('mouseover', '.popup', function()
    {
     console.log("sdsdsds");

     $('body').popover({
            placement: 'bottom',
            container: 'body',
            html: true,
            selector: '[rel="popover"]',
            trigger: 'hover focus',
            title:  'test',
            content: 'foo' 
     });
  });
});

jsfiddle.

Upvotes: 1

Views: 1315

Answers (1)

Ionut Necula
Ionut Necula

Reputation: 11462

Lose the $('body').on('mouseover', '.popup', function() and it will work.

Updated FIDDLE.

If you want to bind the mouseover you can chain it to the popover like this:

$(document).ready(function() {

  $('body').popover({
    placement: 'bottom',
    container: 'body',
    html: true,
    selector: '[rel="popover"]',
    trigger: 'hover focus',
    title: 'test',
    content: 'foo'
  }).on('mouseover', '.popup', function() {
    console.log('test')
  });

});

Upvotes: 3

Related Questions