【问题标题】:Tooltip - Won't hide on mouse out工具提示 - 鼠标移出时不会隐藏
【发布时间】:2016-03-24 03:56:29
【问题描述】:

我已经实现了工具提示。虽然它确实有效,但如果我将鼠标悬停在太快,工具提示不会消失。有没有办法确保工具提示在鼠标移出或点击时隐藏(对于移动设备友好):

 // on mouse over, make a call to DB using AJAX and return results into tooltip
j$( '[data-toggle=tooltip]' ).on( 'mouseover', function( e ){
        var the_Tooltip = j$(this);
        e.preventDefault();
        var tour_ID = the_Tooltip.parent().find('.tour_ID').text();
        var tour_Date = the_Tooltip.parent().find('.tour_Date').text();
        var tour_Date_To = the_Tooltip.parent().find('.tour_Date-to').text();
        var data = {
          "action"    : "testing",
          "tour_ID"   : tour_ID,
          "tour_Date" : tour_Date,
          "tour_Date_To": tour_Date_To
        };
            j$.ajax( {
              url: '../include/vessel-count.php',
              dataType : 'json',
              type : 'POST',
              data: data,
              //cache: false,
              success : function( data ){
                j$(the_Tooltip).tooltip('hide').attr('data-original-title', data.vessel_Info).tooltip('fixTitle').tooltip('show');
                //console.log("returned date: "+data.vessel_Info);
              },
              error: function (request) {
                console.log(request.responseText);
                console.log(request["vessel_Info"]);
              }  
            } );//end ajax
    });

我试过添加这个,但没有运气:

j$( '[data-toggle=tooltip]' ).on( 'mouseout', function( e ){
    j$(this).tooltip('hide');
});

注意 - 当您将鼠标悬停在上面并且工具提示第一次起作用时,它会保持不变。之后每次都按预期工作。

【问题讨论】:

  • 你能分享小提琴吗?
  • @RayonDabre 我无法使用小提琴进行模拟。不知道如何使用 AJAX 让它工作抱歉
  • 你在ajax成功后调用show()..为什么?
  • 返回成功后,我想在工具提示中看到结果
  • 我认为它隐藏了,但是你的 incomplete ajax request,完成并带回来

标签: javascript jquery tooltip


【解决方案1】:

只需从“$”符号中删除“j”,您的代码就可以工作。它对我有用。

$('[data-toggle=tooltip]' ).on( 'mouseout', function( e ){
    $(this).tooltip('hide');
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-22
    • 1970-01-01
    • 1970-01-01
    • 2021-05-30
    • 1970-01-01
    • 1970-01-01
    • 2014-05-08
    • 1970-01-01
    相关资源
    最近更新 更多