简体   繁体   中英

checking if all radio buttons are checked in jquery datatables

I have a datatable and i would like to check if all radio buttons are checked but this works only for the first paginated page but fails to check the other pages

this is my code:

var dt =  $('#newtable').DataTable({
          "paging": true,
          "lengthChange": false,
          "searching": false,
          "ordering": true,
          "info": true,
          "autoWidth": false
        });

This is what am using to check

 $("input:radio").change(function() {
   var all_answered = true;
   dt.rows().nodes().each(function() {
      if($(":radio:checked").length == 0)
      {
        all_answered = false;
      }

   })


  if(all_answered==true ){
      $('input[type=text]#general_comment').removeAttr("disabled");
      approvebtn.removeAttr("disabled");

  }else {
      approvebtn.prop("disabled", "disabled");
  }
});

You can bind a page event on your DataTable once the datatable is initialized, which on pagination (page change) will check what you want.

$('#newtable').bind('page', function () {
    //call to check what you want.
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM