Reza Saadati
Reza Saadati

Reputation: 5421

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!

Upvotes: 1

Views: 399

Answers (2)

Adam S.
Adam S.

Reputation: 146

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

e.g.

$(document.body).tooltip();

Upvotes: 2

dfsq
dfsq

Reputation: 193261

For delegated tooltip functionality you can simply attach handler to parent container, then all inner elements with title attributes will get custom tooltips:

$(document.body).tooltip();

Demo: http://jsfiddle.net/off074wb/

Upvotes: 1

Related Questions