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');
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');
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');
$('*').tooltipster('hide');
–
Vesicant 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 line –
Vesicant 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();
});
.tooltipster('close')
didn't work for me on 3.0.6. But .tooltipster('hide')
worked fine. –
Depew 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');
$('*').tooltipster('hide');
–
Vesicant 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 line –
Vesicant © 2022 - 2024 — McMap. All rights reserved.