This commit is contained in:
2026-07-19 20:10:51 +02:00
parent d7d121b541
commit 5eca2f162b
4 changed files with 56 additions and 28 deletions
+20 -2
View File
@@ -11,6 +11,26 @@ document.addEventListener("DOMContentLoaded", function () {
const parentCommentInput = document.getElementById("parent-comment-id");
const replyInfo = document.getElementById("reply-info");
/**
* Fragt vor dem Löschen eines Kommentars nach einer Bestätigung.
*
* Der Listener funktioniert auch für Kommentare,
* die später per AJAX eingefügt werden.
*/
document.addEventListener("submit", function (event) {
if (!event.target.classList.contains("delete-comment-form")) {
return;
}
const confirmed = confirm(
"Möchtest du diesen Kommentar wirklich löschen?"
);
if (!confirmed) {
event.preventDefault();
}
});
if (!form || !commentsList || !commentContent || !parentCommentInput) {
return;
}
@@ -152,7 +172,6 @@ document.addEventListener("DOMContentLoaded", function () {
<button
type="submit"
class="delete-comment-button"
onclick="return confirm('Möchtest du diesen Kommentar wirklich löschen?');"
>
Kommentar löschen
</button>
@@ -230,7 +249,6 @@ document.addEventListener("DOMContentLoaded", function () {
<button
type="submit"
class="delete-comment-button"
onclick="return confirm('Möchtest du diesen Kommentar wirklich löschen?');"
>
Kommentar löschen
</button>