当用户在弹出窗口之外点击时,防止 JQuery Mobile 关闭弹出窗口

编程入门 行业动态 更新时间:2024-10-28 10:26:17
本文介绍了当用户在弹出窗口之外点击时,防止 JQuery Mobile 关闭弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用 JQuery Mobile 1.2.0 alpha 1.

I'm using JQuery Mobile 1.2.0 alpha 1.

目前,当我打开一个弹出窗口并在屏幕外的任意位置点击它时,弹出窗口正在关闭.我想知道是否有任何我错过的 JQuery Mobile 属性可以设置并防止在外部点击时关闭弹出窗口?(模态弹出窗口)

Currently, when I open a popup and tap outside of it anywhere on the screen the popup is being closed. I was wondering if there's any JQuery Mobile attribute I have missed which can be set and prevent closing the popup upon outside-tap? (modal popup)

(可以找到弹出窗口的文档 这里)

(The documentation for popups can be found here)

我有解决这个问题的想法,但仍然无法实现它:

I had an idea of solving this but still can't implement it to work:

当 JQM 弹出窗口出现时,会有一个 div 覆盖整个屏幕,类为 ui-popup-screen.我想以某种方式给它一个大的 z-index 并从中取消绑定所有单击/点击功能.这样做并不能解决我的问题,但我想这是朝着这个方向迈出的一小步.

When a JQM popup show up theres a div which covers all of the screen with class of ui-popup-screen. I thought somehow to give it a large z-index and unbind all click/tap function from it. Doing this does not solve my problem but I guess it is a small step in the direction.

提前谢谢.

推荐答案

这已作为功能请求添加到 Github.查看问题这里.

This has been added as a feature request on Github. See issue here.

临时解决此问题的方法是取消绑定 ui-popup-screen 上的事件.我会把下面的代码放在pageinit中.

As a hack for this in the interim is to unbind the events on the ui-popup-screen. I would put the following code in the pageinit.

$("#yourPopupId").on({ popupbeforeposition: function () { $('.ui-popup-screen').off(); } });

这是一个繁重的快速修复,但它确实有效.

This is a heavy handed quickfix, but it works.

更多推荐

当用户在弹出窗口之外点击时,防止 JQuery Mobile 关闭弹出窗口

本文发布于:2023-08-06 02:15:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1309464.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:弹出窗口   窗口   用户   在弹出   JQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!