From c30052bac7ae18bbff0cc51f7b11b45e2713e10f Mon Sep 17 00:00:00 2001 From: David Ashby Date: Sat, 14 Oct 2023 17:01:22 -0400 Subject: [PATCH] rollback and fix --- frontend/files/app.js | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/frontend/files/app.js b/frontend/files/app.js index fb4cd0c..2a53e87 100644 --- a/frontend/files/app.js +++ b/frontend/files/app.js @@ -9,28 +9,30 @@ function init() { .then((books) => { // prepare response books.forEach(apiResponseParsing); - document - .getElementById("search") - .addEventListener("input", triggerUpdate); - document - .getElementById("childrens") - .addEventListener("change", triggerUpdate); + document.getElementById("search").addEventListener("input", (e) => { + renderTable( + search( + books, + e.target.value, + document.getElementById("childrens").checked + ) + ); + }); + document.getElementById("childrens").addEventListener("change", (e) => { + renderTable( + search( + books, + document.getElementById("search").value, + e.target.checked + ) + ); + }); 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") {