löschen einer lsite implementiert
This commit is contained in:
1 parent
ae5c28dc8f
commit
782344494c
1 file changed
+32
@@ -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);
|
||||
Reference in new issue
Block a user