Search code examples
javascriptjqueryajaxjquery-uitooltip

Tooltip not working


Since

$(document).ready(function(){
    $('.notice').tooltip();
});

doesn't work for me - probably because I am loading the element with the class .notice dynamically with Ajax - I have tried to go ahead with another way. So this is what I have so far:

$(document.body).on("mouseover", ".notice", function() {
    $(this).tooltip();
});

This makes it work but it causes two problems:

  1. The first time when I hover the element, nothing happens (even no error in the console) but the second time when I hover it, tooltip works!

  2. At the second time when I hover the element, I see the tooltip box and the title box. See image bellow.

    enter image description here

I appreciate any help!


Solution

  • You need to init tooltip when you're creating new ".notice" element.

    e.g.

    $(document.body).tooltip();