How do I check via jQuery if a jQuery Mobile popup is open?

烈酒焚心 提交于 2019-12-05 18:39:21

In jQuery Mobile, a class gets applied to the popup's container when it appears. ui-popup-active when it's visible, ui-popup-hidden when it's hidden. Therefore instead of checking for 'block' or ':visible', you could check for the that class:

if ( $(waiting1).parent().hasClass('ui-popup-hidden')) {
    alert(
        "Error: Waiting popup should not be visible."
    );
    return( -1 );
};

We can use the jQuery Mobile Popup mutex:

if ($.mobile.popup.active && $.mobile.popup.active.element[0] === $(waiting1)[0]) {
alert('popup is opened');
}
umer

Suppose popup has the class popupLogin

if ($.mobile.activePage.find(".popupLogin").parent().hasClass("ui-popup-active")){
     alert('popup is open');
}

See this jsfiddle: http://jsfiddle.net/umerqureshi/fuy4Lz5z/

This worked for me:

if(!$.mobile.activePage.find(popupID).is(":visible")) $(popupID).popup('close');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!