Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery tooltipster plugin, hide all tips?

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');

like image 222
Ivan Juarez Avatar asked Dec 30 '14 17:12

Ivan Juarez


2 Answers

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();
});
like image 85
Louis Ameline Avatar answered Oct 17 '22 03:10

Louis Ameline


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');
like image 4
antyrat Avatar answered Oct 17 '22 02:10

antyrat