Code: Select all
/* using python django template because table template is not in the same html file */
{% include 'my_tbl_template.html' %}
let my_tbl=$('#my_tbl').DataTable({...}),
Code: Select all
Das Problem besteht genau darin, dass my_tbl dies nicht ist Synchronisiert mit dem HTML-Dom, nachdem der Status der Kontrollkästchen manuell geändert wurde! (aktivieren oder deaktivieren);
z. B. wenn ich zwei Kontrollkästchen (2 Zellen) anfangs beide aktiviert habe, wenn der Benutzer eines davon deaktiviert
Code: Select all
printCheckboxStatusDom()
aber< aus br />
Code: Select all
printCheckboxStatusTbl()
Code: Select all
$(document).ready(function(){
$('input[type=checkbox]').change(function() {
printCheckboxStatusDom(); // prints correctly how many checkbox is checked at this time
printCheckboxStatusTbl(); //always prints initialized values (no change)
});
function printCheckboxStatusDom(){
let checkeds = $(document).find('input[type=checkbox]:checked');
console.log('DOM: checked boxes: ' + checkeds.length);
}
/* Function to print checkboxes status in the my_tbl instance */
function printCheckboxStatusTbl() {
my_tbl.rows().every(function (rowIdx, tableLoop, rowLoop) {
let rowNode = this.node();
let cellCheckboxes = $(rowNode).find('input[type=checkbox]:checked');
console.log('Tbl: checked boxes: ' + cellCheckboxes.length);
}
);
}