I need to fire an event when the 'checked' state of any one of several checkboxes is changed, and to do this not by listening for the click. Why?
It looks like this:
BUILD YOUR SUNDAE!
All Flavors [] Chocolate [ ] Vanilla [ ] Strawberry [ ] Pistacchio [ ]
When All Flavors is clicked, all of the other checkboxes are set to be checked:
function checkAllFlavors() {
$("#flavorFilterContainer input.flavor-filter").each(function (i, elem) {
$(elem).prop('checked', true);
});
}
The function above visibly works -- all of the checkboxes are checked. However, if I listen for state-change like this:
("#flavorFilterContainer input.flavor-filter").live('change', function () {
DispenseFlavor()
});
the DispenseFlavor() method is invoked only if I physically click on a checkbox, not if the checkbox's checked state is changed by setting the checked property to true as occurs in the checkAllFlavors() function.
Is the checkbox's changed state altered only by GUI interaction and not via the setting of the property with $(elem).prop('checked', true)
?