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?
$("#days_list li div div div input[type='checkbox']").change(function(){
alert("Someone just clicked checkbox with id"+$(this).attr("id"));
});
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.
$("#checkbox_container input").change(function(){
if($(this).is(":checked")) alert("Checked!");
else alert("Unchecked!");
});
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
$("#checkbox_container input").live("changed"....
Here's an example with some additional scripting and checking, mostly for demonstrative purposes.