Here is the code I use to construct my table:
for (var i = 0; i < result.length; i++) {
var item = result[i];
// Firma, BygningselementNavn, BrugerNavn, EmailAdresse, Telefon
tbody = tbody + '<tr class="modtagerRow"><td>' + item.FirmaNavn + '</td>' +
'<td>' + item.BygningselementNavn + '</td>' +
'<td>' + item.BrugerNavn + '</td>' +
'<td>' + item.EmailAdresse + '</td>' +
'<td>' + item.Telefon + '</td>'
// Medtag
tbody = tbody + '<td style="text-align:center"><input type="checkbox"
value="' + item.BygningselementId + '_' + item.BrugerId + '"
name="BygningsElementBrugerComboIds"></td>' + '</tr>';
}
$('#ModtagereTable tbody').append(tbody)
In attempting to loop through the rows and apply a CSS class to checked checkboxes, I encountered some challenges.
1) While I successfully output the indices to the console, I struggled with creating the if condition for all the checked checkboxes.
2) Additionally, I am uncertain whether I should utilize $( this )
or another method when adding the class .hideForSendMailConfirm
.
// Looping rows in table
$( ".modtagerRow" ).each(function(index, element) {
console.log('index: ' + index);
// if
if (element.checked) {
$( this ).addClass(".hideForSendMailConfirm");
}
});