sam360
sam360

Reputation: 1131

jQuery Mobile 1.4 Nested Popups

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?

Upvotes: 1

Views: 694

Answers (1)

Fr&#233;d&#233;ric Hamidi
Fr&#233;d&#233;ric Hamidi

Reputation: 263017

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

Upvotes: 1

Related Questions