createEditForm implementiert

This commit is contained in:
Technoir committed 2026-10-09 23:06:50 +02:00
1 parent de56ba242c
commit e8319d304a
1 file changed
+30
@@ -10,3 +10,33 @@ export function addList(listAsJSON) {
export function deleteList(listElement) {
listElement.remove();
}
export function createEditListForm(textElement) {
const editForm = document.createElement("form");
const inputName = document.createElement("input");
const abortButton = document.createElement("button");
const saveButton = document.createElement("button");
inputName.setAttribute("name", "newListName");
inputName.setAttribute("value", textElement.querySelector(".list__name").textContent);
inputName.classList.add("editForm__name");
abortButton.textContent = "Abbrechen";
saveButton.textContent = "Speichern";
editForm.appendChild(inputName);
editForm.appendChild(saveButton);
editForm.appendChild(abortButton);
return editForm;
}
export function editList(id, formElement, formData, listLi) {
let newName = formData.newListName;
listLi.querySelector(".list__name").textContent = newName;
listLi.setAttribute("href", `/list/${id}`);
formElement.replaceWith(listLi);
}