Cannot retain checkbox value using jquery.cookie

前端 未结 1 1272
后悔当初
后悔当初 2021-01-17 05:50

I use jQuery DataTable and there is a checkbox on the toolbar that is used for retrieving all records or not. As stateSave feature of DataTab

相关标签:
1条回答
  • 2021-01-17 06:09

    There is no reason to use $.cookie in your case. In the checkbox change event, you can simply store the value of the checked state and use that to set the checked property of the new checkbox generated when you reload the table

    var isChecked;
    $(document).on('change', '#cbIsAll', function () {
        // Store the current value
        isChecked = $(this).is(':checked');
        ....
    

    Then in the datatable's callback function, set the checked state of the checkbox

    $('#cbIsAll').prop('checked', isChecked);
    
    0 讨论(0)
提交回复
热议问题