I am using dataTable for creating a table and everything is working fine. Table consists of a checkbox (column1) and select (last column). So my javascript will only enable select when checkbox is selected. While page to next page, javascript of enabling/disabling is not working. All the selects are enabled.
<script>
var update_selectopt=function(){
$("tr").each(function(){
if($("input[type='checkbox']", this).is(":checked")){
$('#select',this).removeAttr('disabled');
}
else
{
$('#select',this).attr('disabled','disabled');
}
});
};
$(update_selectopt);
$("input[type='checkbox']").on("click",update_selectopt);
</script>
How to manage that?
Fire your update_selectopt
function after the paging event has happened on the table:
$('#table_ws').on( 'page.dt', function () {
update_selectopt();
});
EDIT
Try this:
$('#table_ws').on( 'draw.dt', function () {
update_selectopt();
});
Documentation on page event here
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.