.
This commit is contained in:
+20
-2
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user