class MaestroListRow { constructor(maestroID, maestroName, password, editButton, deleteButton) { this.maestroID = maestroID; this.maestroName = maestroName; this.password = password; this.editButton = editButton; this.deleteButton = deleteButton; } } class MaestroList { constructor(tagDiv, parent) { let self = this; this.parent = parent; // console.log(tagDiv); this.maestroCount = 0; this.activePageNo = 1; let id_list = tagDiv.find(".maestro_id"); // console.log(id_list); this.listRows = new Array(); for(let i = 0; i < id_list.length; i++) { this.listRows[i] = new PaestroListRow( id_list[i], // span $(id_list[i]).siblings(".maestro_name"), $(id_list[i]).siblings(".maestro_password"), $(id_list[i]).siblings(".maestro_edit"), $(id_list[i]).siblings(".maestro_delete") ); this.disableItem(this.listRows[i]); $(id_list[i]).siblings(".maestro_edit").click(function() { parent.editMaestro(this); }) $(id_list[i]).siblings(".maestro_delete").click(function() { parent.deleteMaestro(this); }) // console.log(this.listRows[i].maestroName.val()); // console.log(this.listRows[i]); } } disableItem(item) { $(item.maestroID).empty(); $(item.maestroName).prop("disabled", true); $(item.password).prop("disabled", true); $(item.editButton).prop("disabled", true); $(item.deleteButton).prop("disabled", true); } enableItem(item) { $(item.maestroName).prop("disabled", false); $(item.password).prop("disabled", false); $(item.editButton).prop("disabled", false); $(item.deleteButton).prop("disabled", false); } updatemaestroList(jsonData) { // console.log(jsonData); for(let i = 0; i < 10; i++) { $(this.listRows[i].maestroID).empty(); if(i < jsonData.length) { $(this.listRows[i].maestroID).append(jsonData[i]["maestroID"]); $(this.listRows[i].maestroName).val(jsonData[i]["Name"]); $(this.listRows[i].password).val(jsonData[i]["Password"]); this.enableItem(this.listRows[i]); } else { $(this.listRows[i].maestroName).val(""); $(this.listRows[i].password).val(""); this.disableItem(this.listRows[i]); } } } }