0

ページネーション用に 4 つのボタンがあります (最初、次に移動、前に移動、最後)。ページネーション中にチェックボックスを維持しようとしています。問題は、チェックボックスを選択してから次のページに移動してから同じページに戻ると、以前にチェックされたチェックボックスが表示されないことですが、次のページをクリックするとすぐに、次のページに移動する前に値が表示されますチェック済み。

これが私のコードです。誰かが私が間違っている場所を教えてくれますか?

    $(function() {
        toggleSelectBtnOnCheck();
    });

    function toggleSelectBtnOnCheck() {
        debugger;
        //Register checkbox click handler to be called when Ajax requests complete.
        $('#contentDiv').ajaxComplete(function() {
            $('.tdHeadForCheckboxRadioButton').append('<input class="search" onclick="checkUnchekAllCheckboxes(this);" type="checkbox"/>');
            $('.afirst, .aprev, .anext, .alast, .search:checkbox').click(function() {
                var selectedVal = $(this).closest('td');
                var selectClaim = selectedVal.next().text();
                var selectSuffix = selectedVal.next().next().text();
                var ClaimSuffix = selectClaim + '|' + selectSuffix + ',';
                if ($(this).is(':checked')) {
                    document.getElementById('hdnChkClaim').value += ClaimSuffix;
                } else if ($('#hdnChkClaim').val().indexOf(ClaimSuffix) != -1) {
                    $('#hdnChkClaim').val($('#hdnChkClaim').val().replace(ClaimSuffix, ''));
                }
                alert($('#hdnChkClaim').val());
                if (jQuery(this).attr("href") != "") {
                    //button.disable($('span.btnSelect'));
                    var SelectedItemsCheckboxID = [];
                    if ($('#hdnChkClaim').val() != '') {
                        debugger;
                        if (ClaimSuffix.indexOf(',') != -1) {
                            ClaimSuffix = ClaimSuffix.substr(0, ClaimSuffix.length - 1); //remove last ','
                        }
                        SelectedItemsCheckboxID = $('#hdnChkClaim').val().split(',');
                        for (i = 0; i < SelectedItemsCheckboxID.length; i++) {
                            var claimDetails = SelectedItemsCheckboxID[i].split('|');
                            a = claimDetails[0];
                            b = claimDetails[1];
                            $('tr').filter(function(index) {
                                var columns = $(this).children('td');
                                alert(columns.eq(1).text() === a && columns.eq(2).text() === b);
                                return columns.eq(1).text() === a && columns.eq(2).text() === b;
                            }).find('input:checkbox').attr("checked", true);
                            ;
                        }
                    }
                    if ($('.search:checkbox:checked').length > 0) {
                        button.enable($('span.btnSelect'));
                    } else {
                        button.disable($('span.btnSelect'));
                    }
                }
            });
        });
    }
4

1 に答える 1