I am using tooltip on label hover but this cannot work on mobile, so I decide to use popover on click (touchstart for mobile) instead of tooltips on desktop. This trick I found it here: https://codepen.io/sharperwebdev/pen/mJYRNN
I change my code a little bit because I want when user clicks on label, the popover will be shown only for 1 second. The problem is this is not working perfectly. Because there are some delay issues when user clicks on the same label or clicks quickly on several labels.
I try also to hide all other popovers when a new one is shown but it does not work.
The function .popover('hide')
is not working for me. So I forget it.
Here is my code:
$( function () {
var toolBox = $('[data-toggle="tooltip"]');
toolBox.popover({
template: '<div class="popover ps-popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
}).on('click touchstart', function(e) {
setTimeout(function() {
$('[data-toggle="tooltip"]').popover('hide'); $('.ps-popover').fadeOut('slow'); //hide popover after 1s
}, 1000);
});
})
You can check here for results: https://codepen.io/cutis/pen/qMYrOq