0

I made a simple anchor with a Bootstrap Tooltip on hover. I noticed that the bootstrap tooltip keeps opened when clicking on Anchor and the new tab is opened. Once you go back to the window.opener (in this case the fiddle), the tooltip is still opened, and it closes whenever you do a click on document.

What's the best way to avoid this? I attempted to do a tooltip('destroy') during on click, returning true of course otherwise the anchor href won't work. But it's not working. Tooltip still shows.

Also tried to trigger a document click, but didn't solve it either.

Here's the fiddle. (Noticed the code doesn't work on stackoverflow fiddle, that's why I'm linking it also the jsfiddle)

$(function () {
  $('[data-toggle="tooltip"]').tooltip()
})
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>


<div data-toggle="tooltip" title="Google Link">
  <a href="https://www.google.com" target="_blank">
    Click me!
  </a>
</div>
msqar
  • 2,940
  • 5
  • 44
  • 90

1 Answers1

1

I believe this is the answer you're looking for...

Bootstrap's tooltip doesn't disappear after button click & mouseleave

$(function () {
  $('[data-toggle="tooltip"]').tooltip({trigger : 'hover'})
})
SamJo
  • 26
  • 4
  • Works perfect!!!!! thanks man, i had to initialize the tooltip with {trigger: 'hover' }. Pretty tricky! – msqar Mar 21 '18 at 17:27