event listener für Forms hinzugefügt
This commit is contained in:
1 parent
409469e098
commit
4f453c0263
1 file changed
+19
-1
@@ -1,6 +1,9 @@
|
||||
import * as api from "./listAPI.js"
|
||||
import * as ui from "./listFrontend.js"
|
||||
|
||||
|
||||
const addCategoryForm = document.querySelector(".addCategoryForm");
|
||||
const addItemForm = document.querySelector(".addItemForm");
|
||||
const currentList = document.querySelector(".list");
|
||||
|
||||
function addItem(itemName, itemAmount, categoryID) {
|
||||
@@ -20,8 +23,23 @@ function deleteItem(li) {
|
||||
api.deleteItem(li.id);
|
||||
ui.deleteItem(li);
|
||||
}
|
||||
function init() {
|
||||
|
||||
function init() {
|
||||
addCategoryForm.addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
let formData = Object.fromEntries(new FormData(addCategoryForm));
|
||||
addCategory(formData.categoryName);
|
||||
});
|
||||
|
||||
addItemForm.addEventListener("submit", event => {
|
||||
event.preventDefault();
|
||||
let formData = Object.fromEntries(new FormData(addItemForm));
|
||||
addItem(formData.itemName, formData.itemAmount, formData.itemCategoryID);
|
||||
})
|
||||
|
||||
|
||||
console.log("javascript initialized!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user