Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[Tooltipster Plugin]- Know if div already have tooltipster

I'm using this plugin http://iamceege.github.io/tooltipster/.

It is possible know if a HTML already have the tooltipster initialized?

I wanna know because sometimes i need to change the text of the tooltip, and for do that, i need to destroy the tooltipster, change the attribute title of the HTML object, and initialize again. Like this:

$(this).tooltipster('destroy').attr("title", data.fields[i].value).tooltipster();
like image 956
Ricardo Rocha Avatar asked Aug 26 '15 14:08

Ricardo Rocha


2 Answers

You can use the API:

Check if the element already has tooltipster:

$(...).hasClass("tooltipstered");

$(...).tooltipster('content', myNewContent);
like image 125
Praveen Kumar Purushothaman Avatar answered Oct 27 '22 00:10

Praveen Kumar Purushothaman


Accepted solution does not work on SVG elements with tooltipster v4.1.6. This is how I solved it:

if ($.tooltipster.instances($(node)).length == 0) {
    //it is NOT tooltipstered
}
else {
    //it is tooltipstered
}
like image 24
Gábor Szarka Avatar answered Oct 26 '22 22:10

Gábor Szarka