Datatables with jQuery-toggles not working on pages other than page 1

后端 未结 3 1460
无人共我
无人共我 2021-01-17 01:17

I have a Data-table that is being populated with server-side code.

3条回答
  •  难免孤独
    2021-01-17 02:03

    Just sharing my answer since I am working with Bootstrap Toggle and not JQuery Toggle, but I used some of the accepted answer above:

    $('#tblMyTable').on('draw.dt', function () {
                $('.myInputCheckBoxClass').bootstrapToggle();
    
                fncAdditionalBindingLogicForBoostrapToggle(); //In case you need any logic when you click the toggle button
    
            });
    

    Below code doesn't work since whenever I click the pagination of DataTable, the bindings become erratic, so I used the modified version code above:

    $('#tblCFRMode').on('draw.dt', function () {
    
                  $('.myInputCheckBoxClass').each(function () {
    
                  if ($(this).prop('checked') == true) {
                    $(this).bootstrapToggle('on');
                  } else {
                    $(this).bootstrapToggle('off');
                  }
              });
          });
    

提交回复
热议问题