jquery tooltipster plugin, hide all tips?
Asked Answered
A

2

5

if I have bound tooltipster to input elements and to a diferent elements like a div, is there a way I can hide all in a single call?

So far I know I can to this by hand with:

$('form input').tooltipster('hide'); $('#mydiv').tooltipster('hide');

Atharvaveda answered 30/12, 2014 at 17:2 Comment(0)
V
4

It's simple, you just need to separate your selectors by comma:

$('form input, #mydiv').tooltipster('hide');

If you don't know exact elements that contain tooltipster you can use filter method:

$('*').filter(function() {
    return $(this).data('tooltipsterNs');
}).tooltipster('hide');
Vesicant answered 30/12, 2014 at 17:3 Comment(8)
Yes I know I can do it that way also, but some of the divs are created dynamically and I cannot pass the names into the tooltipster, that is why I want to close them all in a single call dynamically. In fact is a close all function.Atharvaveda
Have you tried to use asterisk as your selector? $('*').tooltipster('hide');Vesicant
do you know a way to close them all in a single call I do not know like with qtip2: $('.qtip.ui-tooltip').qtip('hide');Atharvaveda
Yes and it says that I called "Tooltipster's "hide" method on an uninitialized element". because it will call all elements including those that are not initialized, also using "*" will have some performance issues.Atharvaveda
it will be great to find out which elements are bound witouth knowing their name and at the same time destroy or hide them.Atharvaveda
@IvanJuarez See my updated answer. Unfortunately tooltipster doesn't attach classes or other DOM indicators that can be selected using regular jQuery selectors so only filtering elements by tooltipsterNs data property will help there. And yes, it's bad from performance perspective but I don't see any good solution for this that can be achieved in one lineVesicant
Man you know how to use jQuery correctly, blessings.Atharvaveda
in a further time we will be switching from tooltipster to any other, or simply use bootstrap tooltips.Atharvaveda
F
18

Tooltipster does add a CSS class to elements that have a tooltip attached : "tooltipstered".

So one technique among others is to call

$('.tooltipstered').tooltipster('close');

Edit: with Tooltipster v4, you can actually do this with the public methods, which is always better. Besides, it also works when you use tooltips with the multiple option, while my previous answer does not:

var instances = $.tooltipster.instances();
$.each(instances, function(i, instance){
    instance.close();
});
Flouncing answered 30/12, 2014 at 19:49 Comment(1)
.tooltipster('close') didn't work for me on 3.0.6. But .tooltipster('hide') worked fine.Depew
V
4

It's simple, you just need to separate your selectors by comma:

$('form input, #mydiv').tooltipster('hide');

If you don't know exact elements that contain tooltipster you can use filter method:

$('*').filter(function() {
    return $(this).data('tooltipsterNs');
}).tooltipster('hide');
Vesicant answered 30/12, 2014 at 17:3 Comment(8)
Yes I know I can do it that way also, but some of the divs are created dynamically and I cannot pass the names into the tooltipster, that is why I want to close them all in a single call dynamically. In fact is a close all function.Atharvaveda
Have you tried to use asterisk as your selector? $('*').tooltipster('hide');Vesicant
do you know a way to close them all in a single call I do not know like with qtip2: $('.qtip.ui-tooltip').qtip('hide');Atharvaveda
Yes and it says that I called "Tooltipster's "hide" method on an uninitialized element". because it will call all elements including those that are not initialized, also using "*" will have some performance issues.Atharvaveda
it will be great to find out which elements are bound witouth knowing their name and at the same time destroy or hide them.Atharvaveda
@IvanJuarez See my updated answer. Unfortunately tooltipster doesn't attach classes or other DOM indicators that can be selected using regular jQuery selectors so only filtering elements by tooltipsterNs data property will help there. And yes, it's bad from performance perspective but I don't see any good solution for this that can be achieved in one lineVesicant
Man you know how to use jQuery correctly, blessings.Atharvaveda
in a further time we will be switching from tooltipster to any other, or simply use bootstrap tooltips.Atharvaveda

© 2022 - 2024 — McMap. All rights reserved.