如何判断jquery ui对话框查询是否已初始化? [英] How can I tell if a jquery ui dialog query has been initialized?

查看:93
本文介绍了如何判断jquery ui对话框查询是否已初始化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码来检测jquery ui对话框是否打开:

I have the following code to detect if a jquery ui dialog is open:

if ($("#dialog-myDialog").dialog("isOpen")) {
      return;
}

可以正常工作,但是我发现这种情况是在首先初始化对话框之前调用此代码的,而在这种情况下,此if语句似乎就被炸掉了.

which works fine but I found a situation where this code get called prior to the dialog being initialized in the first place and this if statement seems to just blow up in this case.

检查jquery ui对话框是否已初始化的最佳方法是什么,以便我可以正确处理这种情况.

What is the best way to check if a jquery ui dialog has been initialized so I can properly handle this situation.

推荐答案

测试元素是否具有ui-dialog-content类:

if ($("#dialog-myDialog").hasClass("ui-dialog-content") &&
    $("#dialog-myDialog").dialog("isOpen")) {
    return;
}

这篇关于如何判断jquery ui对话框查询是否已初始化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆