在单击时关闭Bootstrap Popover:在桌面浏览器中工作正常,但在移动浏览器中则无法 [英] Bootstrap Popover Dismiss on Click: Works fine in desktop browser but not in mobile browser
问题描述
因此,我有一个可在nodeJS上运行并在前端使用引导程序的Web应用程序.我已经集成了一些引导程序弹出窗口,并且它们执行以下操作:
So I have a web app that runs on nodeJS and uses bootstrap for the front-end. I have integrated some bootstrap popovers and they do the following:
- 当用户单击或点击图像时,它将弹出弹出窗口.
- 用户可以单击任意位置,它将关闭弹出窗口.
当我从台式机或笔记本电脑浏览器打开应用程序时,它们运行良好,但是当我在移动浏览器(iPhone上的野生动物园)中打开应用程序(使用计算机的IP地址)时,单击时弹出窗口不会消失.这是什么问题我有什么想念的吗?这是代码:
They work fine when I open the app from a desktop or laptop browser, but when I open the app(using computer's IP address) on a mobile browser(safari on iPhone), the popovers do not dismiss on click. What's the problem here? Am I missing anything? Here's the code:
<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不会将点击事件绑定到html
或body
.尝试一下类似的方法(关闭在外部单击时的Twitter Bootstrap Popover ):
I believe iOS does not bind click events to html
or body
. Give something like this a try (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');
}
});
});
希望这会有所帮助.
这篇关于在单击时关闭Bootstrap Popover:在桌面浏览器中工作正常,但在移动浏览器中则无法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!