7

Following this question here on stackoverflow, I created a twitter bootstrap popover that loads on hover. However, the delay is not used, the popover just shows immediately. Here's my code:

$('body').delegate('.withajaxpopover', 'hover', function(event) {
   if (event.type === 'mouseenter') {
      var el=$(this);
      $.get(el.attr('data-load'), function(d) {
      el.popover({delay: { 
                     show: 750, 
                     hide: 100
                  },
                  title: "MyTitle", 
                  content: d}).popover('show', 
                                       {delay: { show: 750, hide: 100 }});
                    });
   } else {
                    $(this).popover('hide');
   }
});
$('body').delegate('.withajaxpopover', 'click', function(event) {
   $(this).popover('hide');
});

The delay is just ignored. What can I do?

Thanks for your help or hints!

Community
  • 1
  • 1
HombreFab
  • 223
  • 1
  • 4
  • 7
  • 3
    Did you know that delay `does not apply to manual trigger type` ? [doc](http://twitter.github.com/bootstrap/javascript.html#popovers) - and doing `popover('show')` is like manual. And passing an object as 2nd parameter will certainly have no effect at all. – Sherbrow Aug 07 '12 at 10:29
  • 2
    No, I did not know that before. But how can I show the popover, if not using `popover('show')`? – HombreFab Aug 07 '12 at 10:58
  • 1
    Delay and popovers are kind of messy... [github issue](https://github.com/twitter/bootstrap/issues/512). Would that [jsfiddle](http://jsfiddle.net/Sherbrow/ERY4S/) work ? – Sherbrow Aug 07 '12 at 12:49

1 Answers1

7

Had a similar issue, solved it by focusing the obj. Would look something like this...

$('#yourobj').popover({
    trigger: 'focus',
    delay: 1000
 }).focus();

even better with a timeout, if you want a manual trigger..

setTimeout(function() {
  $('#yourobj').popover('show');
}, 500);

Hope is helps someone else...

CaptainAl
  • 71
  • 1
  • 5