From 782344494c3fc4f489831a35a6cfc752aa5e079e Mon Sep 17 00:00:00 2001 From: Tim Aldinger Date: Sun, 4 Oct 2026 17:09:19 +0200 Subject: [PATCH] =?UTF-8?q?l=C3=B6schen=20einer=20lsite=20implementiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/static/js/index.js | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/resources/static/js/index.js diff --git a/src/main/resources/static/js/index.js b/src/main/resources/static/js/index.js new file mode 100644 index 0000000..60e1eec --- /dev/null +++ b/src/main/resources/static/js/index.js @@ -0,0 +1,32 @@ +import { ShoppingList } from "./ShoppingList.js"; + + +const deleteListButtons = document.querySelectorAll('.shoppingListOverview__deleteListButton'); +const shoppingLists = []; + + +function fillList() { + document.querySelectorAll('.shoppingListOverview__shoppingList') + .forEach(list => { + shoppingLists.push(new ShoppingList(list.id)); + console.log(list.id); + }); + +} + +function deleteList(id) { + fetch(`/api/list/${id}`, { method: "DELETE" }).then(r => console.log("Liste entfernt")) +} + + +function init() { + deleteListButtons.forEach(button => { + button.addEventListener("click", () => { + const id = button.dataset.id; // liest data-id + deleteList(id); + }); + }); + fillList(); +} + +document.addEventListener('DOMContentLoaded', init);