0

Is there any way we can hide bootstrap tool-tips instead of destroying them.

I am using server side data in tool-tips and I don't want to load data every time a tool-tip is initiated.

$('.selector').popover({
  animation: true,
  trigger: 'click',
  title: 'Notifications',
  content: 'No new notificaitons',
  placement: 'right',
  container: 'body',
  html: true,
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js" integrity="sha384-u/bQvRA/1bobcXlcEYpsEdFVK/vJs3+T+nXLsBYJthmdBuavHvAW6UsmqO2Gd/F9" crossorigin="anonymous"></script>

<span class="selector">selector</span>
hussain nayani
  • 317
  • 1
  • 3
  • 14

1 Answers1

0

You don't have to hide your tooltip, you have an other way.

You can load your server side data in a global object and use this object when you open your tooltip.

In this case, your data is load only one times, and you don't have to change the tooltip.

Example :

var myObject = {};

$.get(PHP_PAGE, DATAS).done(function(data){
     //HERE GET YOUR DATA LIKE
     myObject = data;
});

...


$('.selector').popover({
  animation: true,
  trigger: 'click',
  title: myObject.title,
  content: myObject.contentMessage,
  placement: 'right',
  container: 'body',
  html: true,
})
B3ND3L
  • 1
  • 1
  • 2
  • Actually I am using a plugin which has to be initiated on any element, and that plugin fetches the data from the server. So I can not store data in any variable. . – hussain nayani Jun 05 '18 at 11:02