javascript - Bootstrap Popover 点击时关闭 : Works fine in desktop browser but not in mobile browser

标签 javascript ios twitter-bootstrap popover

所以我有一个在 NodeJS 上运行并使用 bootstrap 作为前端的 Web 应用程序。我集成了一些 Bootstrap 弹出窗口,它们执行以下操作:

  1. 当用户点击或点击图像时,将会弹出弹出窗口。
  2. 用户可以单击任意位置,它将关闭弹出窗口。

当我从台式机或笔记本电脑浏览器打开应用程序时,它们工作正常,但是当我在移动浏览器(iPhone 上的 safari)上打开应用程序(使用计算机的 IP 地址)时,弹出窗口不会在单击时消失。这里有什么问题?我错过了什么吗?代码如下:

<img src='/images/question.png' tabindex="0" role="button" data-trigger="focus" height="10" width="10" data-toggle="popover" title="Daily Hub Activity" data-content="Lorem ipsum blablabla." animation="true" data-placement="bottom">

最佳答案

我相信 iOS 不会将点击事件绑定(bind)到 htmlbody。尝试一下这样的事情( Close a Twitter Bootstrap Popover when Clicking Outside ):

$('[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');
        }
    });
});

希望这有帮助。

关于javascript - Bootstrap Popover 点击时关闭 : Works fine in desktop browser but not in mobile browser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30626171/

相关文章:

javascript - Angular Js - TypeError : Object doesn't support property or method "includes"

ios - 切换到另一个应用程序/主屏幕时如何完全关闭 iOS 应用程序(删除它使用的 RAM)

html - Bootstrap 列不起作用

javascript - YouTube 播放器 Internet Explorer 故障

javascript - 如何创建后退/前进按钮?

iphone - 在这种情况下我应该使用全局 bool 变量吗?

ios - 如何安全地移除观察者 (Swift)

html - 无法在 Twitter Bootstrap 3 列网格中放置面板

javascript - Bootstrap 所有子菜单同时打开

javascript - 传单 Angular Directive(指令)中的 KML