This commit is contained in:
parent
e8c3da4ac8
commit
c30052bac7
@ -9,28 +9,30 @@ function init() {
|
|||||||
.then((books) => {
|
.then((books) => {
|
||||||
// prepare response
|
// prepare response
|
||||||
books.forEach(apiResponseParsing);
|
books.forEach(apiResponseParsing);
|
||||||
document
|
document.getElementById("search").addEventListener("input", (e) => {
|
||||||
.getElementById("search")
|
renderTable(
|
||||||
.addEventListener("input", triggerUpdate);
|
search(
|
||||||
document
|
books,
|
||||||
.getElementById("childrens")
|
e.target.value,
|
||||||
.addEventListener("change", triggerUpdate);
|
document.getElementById("childrens").checked
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
document.getElementById("childrens").addEventListener("change", (e) => {
|
||||||
|
renderTable(
|
||||||
|
search(
|
||||||
|
books,
|
||||||
|
document.getElementById("search").value,
|
||||||
|
e.target.checked
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
renderTable(
|
renderTable(
|
||||||
search(books, "", document.getElementById("childrens").checked)
|
search(books, "", document.getElementById("childrens").checked)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggerUpdate() {
|
|
||||||
renderTable(
|
|
||||||
search(
|
|
||||||
books,
|
|
||||||
document.getElementById("search").value,
|
|
||||||
document.getElementById("childrens").checked
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderTable(books, sortField) {
|
function renderTable(books, sortField) {
|
||||||
if (sortField) {
|
if (sortField) {
|
||||||
if (sortState.sortBy === sortField && sortState.sortOrder === "asc") {
|
if (sortState.sortBy === sortField && sortState.sortOrder === "asc") {
|
||||||
|
Loading…
Reference in New Issue
Block a user