jQuery Mobile 1.4 Nested Popups

て烟熏妆下的殇ゞ 提交于 2020-01-15 10:56:26

问题


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>

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


回答1:


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.

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);
    };
});


来源:https://stackoverflow.com/questions/21679412/jquery-mobile-1-4-nested-popups

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!