如果jQuery Mobile弹出窗口打开,如何通过jQuery检查?

问题描述 投票:2回答:4

我可以激活以下jQuery Mobile弹出窗口:

<div data-role="popup" id="waiting1" data-overlay-theme="a" data-corners="false" data-tolerance="30,15" data-dismissible="false">
     <div class="modalAlert" id="waitingContent">
      Waiting...
     </div> 
</div>

使用jQuery命令:

$(waiting1).popup('open');

但后来我想以编程方式确认弹出窗口打开,如果没有,则使用IF语句触发警报。我尝试使用CSS显示属性:

if ( $(waiting1).css('display') != 'block') {
    alert(
        "Error: Waiting popup should not be visible."
    );
    return( -1 );
};

...但作为一个jQuery Mobile弹出窗口,显然该属性始终是“阻止”,无论它是否可见。在IF语句中检查这个的正确方法是什么?谢谢你的帮助。

jquery jquery-mobile popup
4个回答
8
投票

在jQuery Mobile中,类出现时会应用于弹出窗口的容器。当qzxswpoi可见时,ui-popup-active隐藏起来。因此,您可以检查该类,而不是检查ui-popup-hidden'block'

':visible'

2
投票

我们可以使用jQuery Mobile Popup互斥锁:

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

1
投票

假设popup有类popupLogin

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

看到这个jsfiddle:if ($.mobile.activePage.find(".popupLogin").parent().hasClass("ui-popup-active")){ alert('popup is open'); }


0
投票
© www.soinside.com 2019 - 2024. All rights reserved.