löschen einer lsite implementiert

This commit is contained in:
Technoir committed 2026-10-04 17:09:19 +02:00
1 parent ae5c28dc8f
commit 782344494c
1 file changed
+32
+32
View File
@@ -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);