Twitter Bootstrap Popover/Tooltip Bug with Mobile?

后端 未结 6 1254
执念已碎
执念已碎 2021-02-19 05:24

I am working with Twitter Bootstrap and ran into something I could not fix when testing on iPad and iPhone. On mobile (at least those devices) you need to click to engage the t

6条回答
  •  遇见更好的自我
    2021-02-19 06:12

    Refer following code snippet to get it works:

    $('[data-toggle="popover"]').popover();
    
    $('body').on('click', function (e) {
      $('[data-toggle="popover"]').each(function () {
        //the 'is' for buttons that trigger popups
        //the 'has' for icons within a button that triggers a popup
        if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
          $(this).popover('hide');
        }
      });
    });
    

    This is the easiest way of detecting clicks on the body and close all the tooltips on the page.

    You can check the live example here

提交回复
热议问题