防止JQuery Mobile在用户点击弹出窗口时关闭其弹出窗口 [英] Prevent JQuery Mobile from closing a popup when user taps outside of it

查看:134
本文介绍了防止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.

提前Thnx.

推荐答案

已作为功能请求添加到Github.参见问题此处.

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

为此,在此过程中,可以取消ui-popup屏幕上的事件的绑定.我会将以下代码放在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在用户点击弹出窗口时关闭其弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆