Mundane, a common use case
I would like the tooltip to display the loaded GIF immediately on mouseover, which is replaced by HTML as a result of the AJAX success callback. There are almost as many broken answers to AJAX tips as people asking this exact question online. In particular, I motivated my efforts on this , this , and especially a few answers here .
The problem that I constantly encounter in all these solutions, even those who specifically require a solution to this problem, is that tool tips sometimes appear late and do not disappear. This is not a library issue either, because I had the same problem in the past with jQuery-UI tool tips.
Libraries
- jQuery v2.2.3
- Bootstrap v3.3.6
They used to try using jQuery 1 and had the same problem:
My page also relies on the jQuery Datatables v1.10.11 library, but this is orthogonal to the hint problem, different from the fact that my particular use case generates more and more AJAX tooltip requests with variable delays, which increases the likelihood of seeing "sticking problems "
Current attempt
"towr" , . , , , "" .
, AJAX , $( ".tooltip-cell" ).on( "mouseover", set_tooltip ), set_tooltip - ,
var $e = $(this);
if( $e.attr( "title" ) === undefined ) {
$e.attr( "title", "<img src='images/wait.gif'/>" );
$e.tooltip(
{
html: true,
trigger: "hover"
}
).tooltip( "show" );
$.ajax(
{
url: "ajax/tooltip_data.php",
data:
{
lookup_id: $e.attr("lookup_id")
},
success:
function(response) {
$e.attr( "title", response ).tooltip( "fixTitle" );
if( $e.is( ":hover" ) ) {
$e.tooltip( "show" );
}
},
dataType: "html"
}
);
}
AJAX. , -, .is(":hover") , , $( ":focus :active" ).filter( $e ).length > 0, , , . , setTimeout( function() {}, 2000 );, . . , 10 , , 2 AJAX HTML , , . , if( <hover-check> ) , , 10 , - , .
The Crux
, , , , ?
, , .
1) .tooltip() undefined, jQuery JS <head>, Bootstrap JS include HTML. Bootstrap, jQuery ( jQuery Bootstrap), .
2) , , $el.data(...) undefined $el.data('tooltip').tip().is(':visible') . , .
, , , 16 (, , 16) , , , , , .