jQuery Mobile 1.4嵌套弹出窗口 [英] jQuery Mobile 1.4 Nested Popups

查看:94
本文介绍了jQuery Mobile 1.4嵌套弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JQM 1.4,我不再可以从另一个弹出窗口中打开新的弹出窗口.

Using JQM 1.4, I no longer can open a new popup from another popup.

<a href="#popupBasic" data-rel="popup" 
 class="ui-btn ui-corner-all ui-shadow ui-btn-inline" 
data-transition="pop">Basic Popup</a>

<div data-role="popup" id="popupBasic">
   <p>This is a completely basic popup, no options set.</p>
   <a href="#popupBasicAnother" data-rel="popup" class="ui-btn ui-corner-all ui-shadow ui-btn-inline" data-transition="pop">Another Popup</a> 
</div>

<div data-role="popup" id="popupBasicAnother">
  <p>Another Popup</p>
</div>

这在1.3版本中工作正常. 知道我该如何解决吗?

This was working fine in 1.3 version. Any idea how I can fix this?

推荐答案

这是由于更改了在弹出窗口小部件内单击的链接的处理方式而引起的.在jQuery Mobile 1.3中,当前活动的弹出窗口被强制关闭,因此可以打开新的弹出窗口. jQuery Mobile 1.4不再是这种情况.

This comes from a change in the way links clicked inside a popup widget are handled. In jQuery Mobile 1.3, the currently active popup was forcibly closed so the new one could be opened. This is no longer the case in jQuery Mobile 1.4.

要恢复以前的行为,可以在 mobileinit 处理程序中修补$.mobile.popup.handleLink():

To restore the previous behavior, you can patch $.mobile.popup.handleLink() in a mobileinit handler:

$(document).on("mobileinit", function() {
    var originalHandleLink = $.mobile.popup.handleLink;
    $.mobile.popup.handleLink = function(link) {
        var activePopup = $.mobile.popup.active,
            path = $.mobile.path;
        if (activePopup) {
            var popup = $(path.hashToSelector(
                path.parseUrl(link.attr("href")).hash)).first();
            if (popup.length > 0 && popup.data("mobile-popup")) {
                activePopup._close(true);
            }
        }
        originalHandleLink.apply(this, arguments);
    };
});

这篇关于jQuery Mobile 1.4嵌套弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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