问题描述
我能够激活以下jQuery Mobile弹出窗口:
I'm able to activate the following jQuery Mobile popup:
<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命令:
using the jQuery command:
$(waiting1).popup('open');
但是我想以编程方式确认弹出窗口是否打开,如果没有,则使用IF语句触发警报.我尝试使用CSS显示属性:
but then I want to confirm programmatically that the popup opened, and trigger an alert using an IF statement if it didn't. I tried using the CSS display attribute:
if ( $(waiting1).css('display') != 'block') {
alert(
"Error: Waiting popup should not be visible."
);
return( -1 );
};
...但是作为jQuery Mobile弹出窗口,无论该属性是否可见,该属性显然始终是阻止"的.在IF语句中检查此内容的正确方法是什么?感谢您的帮助.
...but as a jQuery Mobile popup, apparently the attribute is always "block" whether it's visible or not. What's the proper way to check this within the IF statement? Thanks for any help.
推荐答案
在jQuery Mobile中,一个类在弹出窗口的容器出现时被应用. ui-popup-active
可见时,ui-popup-hidden
隐藏时.因此,您可以检查该类,而不是检查'block'
或':visible'
:
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 );
};
这篇关于如何通过jQuery检查jQuery Mobile弹出窗口是否打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!