Checkbox wont show as checked past page 1

Checkbox wont show as checked past page 1

jamesjw007jamesjw007 Posts: 35Questions: 0Answers: 0
edited June 2012 in General
By default I show 10 records for the table. Clicking the check box will check the box correctly for these 10 records. I use server side as well to mark if the box should or should not be checked. I use Ajax to add them to the 'monitor list' which means the box should be checked.

This works 100% on page 1. I load the table the correct records show as checked, I check them, reload the page they remain checked as they should. I uncheck them reload the page and they remain unchecked.

However when I paginate to page 2, I click on the check box the box remains unchecked. However my Ajax correctly fires, and adds them to the database as it should. I reload the page and paginate to page 2 and they are still unchecked (the actual input is checked, the parent span tag does not have the 'checked' class).

Here is the script I copied from here i believe to make sure the parent 'span' gets the checked class which works when I am on page 1 of the table.

[code]
//for checkbox
jQuery('input[type=checkbox]').each(function () {
var t = jQuery(this);
t.wrap('');
t.click(function () {
if (jQuery(this).is(':checked')) {
t.attr('checked', true);
t.parent().addClass('checked');
} else {
t.attr('checked', false);
t.parent().removeClass('checked');
}
});
if (t.is(':checked')) {
t.attr('checked', true);
t.parent().addClass('checked');
}
});
[/code]

Can anyone see what might be happening so items past page 1 of the table do not get checked? I tried to change t.click to t.live('click' and that didn't fix it as well.

Any help is appreciated!
This discussion has been closed.