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.
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")
.
How do I determine if that domObj
has a progressbar
attached?
You can access the progress bar object on the element by doing:
$("#myid").data("progressbar")
So to use this:
var progressBar = $("#myid").data("progressbar");
if ( progressBar == null ) {
// handle case when no progressbar is setup for my selector
} else {
alert("The value is: " + progressBar.value());
}