tonelm54
asked on
Add Handler to all and then call them all
Im trying to add a handler to all checkboxes:-
And then call them all by:-
The idea is to add a save to each element, so when the value is saved it executes a ajax request to save the value, but when then are all disabled (done by a button called disableAll) I want it to run the save code on all of the elements (ie run the onChange handler on all the elements).
Something is happening with the trigger as the code takes a few seconds to run, but what I dont know as it doesnt display any alert boxes to me.
Can anyone assist?
$('document').ready(function () {
$(':checkbox').change(function () {
alert((this).id());
});
});
And then call them all by:-
$(':checkbox').are(':checked').trigger('change');
The idea is to add a save to each element, so when the value is saved it executes a ajax request to save the value, but when then are all disabled (done by a button called disableAll) I want it to run the save code on all of the elements (ie run the onChange handler on all the elements).
Something is happening with the trigger as the code takes a few seconds to run, but what I dont know as it doesnt display any alert boxes to me.
Can anyone assist?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
http://jsfiddle.net/j08691/pzCcE/2/