需要知道 jQuery UI Widget 是否已应用于 DOM 对象 [英] Need to know if a jQuery UI Widget has been applied to a DOM object

查看:22
本文介绍了需要知道 jQuery UI Widget 是否已应用于 DOM 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jQuery 并与需要获取选项的 jQuery UI 进行一些交互.然而,jQuery UI 函数可能尚未应用于 DOM 对象.我现在在访问选项时遇到 JavaScript 错误.

I'm using jQuery and have some interactions with a jQuery UI where I need to get options. However there's a possibility that the jQuery UI function has not been applied yet to the DOM object. I'm getting a JavaScript error right now when I access an option.

我有一个带有进度条的 DOM 对象 (http://docs.jquery.com/UI/进度条)附加到它(也许).在另一个线程中,我正在尝试使用 domObj.progressbar("option", "value") 访问选项.

I have a DOM object that has the progressbar (http://docs.jquery.com/UI/Progressbar) attached to it (maybe). In another thread, I'm trying to access the options using domObj.progressbar("option", "value").

如何确定 domObj 是否附加了 progressbar?

How do I determine if that domObj has a progressbar attached?

推荐答案

DOM 对象会附加一个额外的 CSS 类:ui-progressbar".如果您在 http://docs.jquery.com/UI/Progressbar 上查看源代码,那么您可以看到一个 id=progressbar 的 div,仅此而已,但是如果您使用 Firebug 并单击该元素,您可以看到它添加了更多的类.

The DOM object will get an extra CSS class appended to it: "ui-progressbar". If you View Source on http://docs.jquery.com/UI/Progressbar then you can see a div with id=progressbar and nothing more, but if you use Firebug and click the element you can see it has a few more classed added.

已我认为@jamiebarrow 的解决方案在这里更正确.

Edited: I think that @jamiebarrow's solution is the more correct one here.

这篇关于需要知道 jQuery UI Widget 是否已应用于 DOM 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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