Bootstrap's tooltip doesn't disappear after button click & mouseleave

前端 未结 22 917
感情败类
感情败类 2020-12-07 16:24

I have a problem with bootstrap\'s tooltip : When I click on a button, tooltip stays even if is the cursor is outside of the button. I have looked into the manual - Bootstra

22条回答
  •  春和景丽
    2020-12-07 16:53

    Using delegation to make it ajax friendly,

    // if you're not using turbolinks, then you can remove this parent wrapper
    $(document).on('turbolinks:load'), function() {  
      // enable tooltip with delegation to allow ajax pages to keep tooltip enabled
      $('body').tooltip({
        select: "[data-toggle='tooltip']"
      });
    
      // remove old tooltip from sticking on the page when calling ajax with turbolinks
      $('body').on('click', "[data-toggle='tooltip']", function() {
        $(this).tooltip('dispose');
      });
    });
    

提交回复
热议问题