1

I'm having an issue where my tooltip from Tooltipster is showing the same data everytime I hover a new element, instead of showing new dynamic data everytime I hover a new element.

How can I fix my code so that only one tooltip shows with new dynamic data each time I hover?

I hover an element that's supposed to activate it, creating this console message: "Tooltipster: one or more tooltips are already attached to this element: ignoring. Use the "multiple" option to attach more tooltips."

Using the 'multiple' option works by generating new tooltips that shows the proper data, but this causes the tooltips to stack on top of each other instead of replacing itself.

function showAsynchronousTooltipForTopicWithName(name) {
  var urlToSend = '/API/v1/topic?name='+encodeURIComponent(name.trim());
  $.ajax({
    type: "GET",
    url: urlToSend,
     success: function (result) {
        showNotification("API Success", 'success');
        showTopicsTooltips(result);
    },
    error: function (result) {
        showNotification("Something went wrong", 'error')
    }
  });
}

function showTopicsTooltips(response) {
  var topic = response;
  console.log(topic['name']);
  // create content based on experts_internal and experts_external properties

  $('.tooltip-topics').tooltipster({
            animation: 'fade',
            theme: 'tooltipster-shadow',
            trigger: 'hover',
            viewportAware: true,
            contentAsHTML: true,
            multiple: true,
            content:  '<div>' +
                      '<p><b>Team Experts</b></p>' +
                      '<p>'+ topic['experts_internal'] + '</p>' +
                      '<p><b>External Experts</b></p>' +
                      '<p>'+ topic['experts_external'] + '</p>' +
                      '</div>'
  });
}

I was expecting the tooltip to replace the data dynamically every time I hover a different element that has the tooltip, but right now without 'multiple' option it keeps showing the same data for each element, and with 'multiple' option it just generates a new tooltip everytime without removing the last so they end up stacking.

Cosmin Staicu
  • 1,809
  • 2
  • 20
  • 27
Chris Mok
  • 107
  • 5

0 Answers0