I am using jQuery and jQuery UI and i am trying to read a checkbox state through the addition of the “aria-pressed” property that jQuery UI Button toggle between false and true.
$('.slideButton').live('click', function() {
alert($(this).attr('aria-pressed'));
});
This code however seems to read the aria-pressed before jQuery UI has updated aria-pressed. So i unreliable values. Can i schedule it to execute after the UI has updated or can i make it wait?
Can’t you add a listener to the actual checkbox behind the label or span?
This should work since, once you click the label, you change the value in the checkbox.
Alright, I’ve composed a live example for you that demonstrates the general idea of how it works, and how you retrieve the status of the checkbox.
In your case, since the checkbox is added dynamically by JQuery you have to use the live event, but it is basically the same thing
Here’s an example with some additional scripting and checking, mostly for demonstrative purposes.