3

I'm trying to change the delay option in a Bootstrap popover on click. I wish the result to be such that when you click the second button the popover shows immediately, but it doesn't and I don't know why.

I tried to use dispose, disable, hide and none of them works. Does anyone have any ideas?

$('[data-toggle="popover"]').popover({
  trigger: "hover",
  delay: {
    show: 1000,
    hide: 150
  }
})

$('#popOnAnother').click((event) => {
  $('#popOnIt').popover('toggle')
})
<script type="text/javascript" src="//code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link rel="stylesheet" type="text/css" href="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script type="text/javascript" src="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

<button id="popOnIt" data-toggle="popover" data-content="work please">
  I want to pop after deley on hover
</button>
<button id="popOnAnother">
  show pop on another button RIGHT NOW!
</button>

jsFiddle: https://jsfiddle.net/L4tmhux1/11/

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
MacOne
  • 33
  • 6

1 Answers1

2

You could wrap the Button with the Popover element in a div and instead of toggling the popover of the button you create new popover on the wrapper and toggle that.

<div id="wrap">
  <button id="popOnIt" data-toggle="popover" data-content="work god damn it">
     I want to pop after deley on hover
  </button>
</div>


$('#popOnAnother').click((event)=>{
  $('#wrap').popover({
    content: $('#popOnIt').data('content')
  }).popover('toggle');
});

JSFiddle

Lapskaus
  • 1,709
  • 1
  • 11
  • 22