Reputation: 4865
We are utilizing the tooltipster plugin to display a tooltip over an info icon. This works fine on hover. But we also need to have it show if someone tabs to the info icon too.
I can't seem to find any examples of how to enable the popup on both hover AND focus.
This is what existed in this project already:
HTML:
<a href="#"><span class="tooltip">Some handy tooltip text...</span></a>
Javascript:
if ($('.tooltip').length) {
$('.tooltip').tooltipster({
theme: '.tooltipster-shadow',
maxWidth: 220,
interactive: true,
functionReady: function () {
$('html').click(function () {
$.fn.tooltipster('hide');
});
}
});
}
Upvotes: 2
Views: 3569
Reputation: 181
I think you are looking for that :
$('.tooltip_hover_n_click').tooltipster({
delay: 100,
trigger: 'custom' // disable all by default
}).mouseover(function(){ // show on hover
$(this).tooltipster('show');
}).blur(function(){ // on click it'll focuses, and will hide only on blur
$(this).tooltipster('hide');
}).mouseout(function(){ // if user doesnt click, will hide on mouseout
if(document.activeElement !== this){
$(this).tooltipster('hide');
}
});
Upvotes: 1
Reputation: 61114
You can use Tooltipster's show method like so:
$('.tooltip').tooltipster().focus(function() {
$(this).tooltipster('show');
});
http://iamceege.github.io/tooltipster/#advanced
Upvotes: 4
Reputation: 36703
$('.tooltip').tooltipster({
theme: '.tooltipster-shadow',
trigger: 'custom',
maxWidth: 220,
interactive: true,
functionReady: function () {
$('html').click(function () {
$.fn.tooltipster('hide');
});
}.on( 'focus, hover', function() {
$( this ).tooltipster( 'show' );
}).on( 'focusout, mouseout', function() {
$( this ).tooltipster( 'hide' );
})
});
Upvotes: 0