re-render when children's checkbox toggles
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
David 2023-10-14 16:57:22 -04:00
parent f282b10c05
commit e8c3da4ac8

View File

@ -9,21 +9,28 @@ function init() {
.then((books) => {
// prepare response
books.forEach(apiResponseParsing);
document.getElementById("search").addEventListener("input", (e) => {
renderTable(
search(
books,
e.target.value,
document.getElementById("childrens").checked
)
);
});
document
.getElementById("search")
.addEventListener("input", triggerUpdate);
document
.getElementById("childrens")
.addEventListener("change", triggerUpdate);
renderTable(
search(books, "", document.getElementById("childrens").checked)
);
});
}
function triggerUpdate() {
renderTable(
search(
books,
document.getElementById("search").value,
document.getElementById("childrens").checked
)
);
}
function renderTable(books, sortField) {
if (sortField) {
if (sortState.sortBy === sortField && sortState.sortOrder === "asc") {