So I have to work with Knack and i want to update multiple Datasets. I choose those with checkboxes. I add those checkboxes dynamically to the Table and also the ID is added dynamically. Problem is that the Table got several pages and I need to safe the state so updating those sets is easier.
var addCheckboxes = function(view) {
// add checkbox to select / unselect all checkboxes
$('#' + view.key + '.kn-table thead tr').prepend('<th><input type="checkbox"></th>');
$('#' + view.key + '.kn-table thead input').change(function() {
$('.' + view.key + '.kn-table tbody tr input').each(function() {
$(this).attr('checked', $('#' + view.key + '.kn-table thead input').attr('checked') != undefined);
});
});
// add a checkbox to each row in the table body
$('#' + view.key + '.kn-table tbody tr').each(function() {
var inputlmnts = document.getElementsByTagName("input"),
count = 0;
for (var i = 0; i < inputlmnts.length; i++) {
if (inputlmnts[i].type === "checkbox") {
count++;
}
}
$(this).prepend('<td><input type="checkbox" class= tablechb id = ' + i + '></td>');
});
I couldn't get behind how to save the Checkbox-State to the localStorage.
Aucun commentaire:
Enregistrer un commentaire