jQuery UI对话框-通过实例方法检查是否存在 [英] jQuery UI dialog - check if exists by instance method

查看:51
本文介绍了jQuery UI对话框-通过实例方法检查是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用instance方法测试jQuery UI Dialog小部件是否已初始化.关于 API ,这是可能的,但它对我不起作用:

I'd like to use instance method for testing if jQuery UI Dialog widget has been initialized or not. Regarding to API, this is possible, but it doesn't work for me:

Uncaught Error: cannot call methods on dialog prior to initialization; attempted to call method 'instance'

演示: http://jsfiddle.net/mDbV7/

更新:

这是文档中的错误,instance方法将从1.11.0版本开始可用,请参见此问题.

This was a mistake in the documentation, instance method will be available from version 1.11.0, see this issue.

推荐答案

最新版本的jQuery UI不再允许您对尚未初始化的项目调用UI方法.我只是将它们包装在if语句中,例如:

The latest version of jQuery UI no longer allows you to call UI methods on items that are not initialized yet. I've just been wrapping them in an if statement, like:

if ($("#divToBeDialoged").hasClass('ui-dialog-content')) {
    // do whatever
} else {
    // it is not initialized yet
}

更改了班级名称,谢谢@dmnc

changed class name, thanks @dmnc

这篇关于jQuery UI对话框-通过实例方法检查是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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