calebjacob / tooltipster

A jQuery tooltip plugin
MIT License
2.76k stars 482 forks source link

Using $('.ttip').tooltipster('open') causes incorrect position #784

Closed MagusX closed 4 years ago

MagusX commented 4 years ago

When submitting invalid field the page is reloaded and I want the tooltip to appear when page loaded so I use tooltipster('open') listed in the doc example. But the tooltip doesn't appear at the (!) icon position, it's about some hundreds pixels to the left of the icon. The position is correct when I resize the window or F12 or hover cursor on the icon. Like when I do these things the tooltip jumps right back to its correct position but not the first time. I did all the steps to solve this in the FAQ but didn't help.

<span style="color:rgb(240,0,0);font-size:15px; position: absolute;" class="fas fa-exclamation-circle ttip" data-tooltip-content="#ttip_content1"></span>

<div class="tooltip_templates">
  <span id="ttip_content1">@ViewBag.ErrorMessage</span>
</div>
$(document).ready(function () {
  $('.ttip').tooltipster({
    theme: 'tooltipster-noir'
  });

  $('.ttip').tooltipster('open');
  $(window).keypress(function() {
      $('.ttip').tooltipster('close');
   });
}
louisameline commented 4 years ago

Hello, my guess is that you need to wait for images in the page to have finished loading. Try to open the tooltip after a setTimeOut to verify this theory.

MagusX commented 4 years ago

You are right, I have to wait for the other elements to have loaded. Thank you so much.