Update the comment delete function of the moderator to remove jQuery

This commit is contained in:
William Karsten 2022-06-10 10:56:08 -05:00
parent c5e44bbe25
commit d3358e5406
1 changed files with 15 additions and 12 deletions

View File

@ -401,18 +401,6 @@ $(document).ready(function() {
}
});
$(document).on("click", "a.comment_moderator", function() {
var reason = prompt("Moderation reason:");
if (reason == null || reason == "")
return false;
var li = $(this).closest(".comment");
$.post("/comments/" + $(li).attr("data-shortid") + "/delete",
{ reason: reason }, function(d) {
$(li).replaceWith(d);
});
});
Lobsters.runSelect2();
$(document).on("blur", "#story_url", function() {
@ -611,5 +599,20 @@ onPageLoad(() => {
});
}
});
on('click', 'a.comment_moderator', (event) => {
const reason = prompt("Moderation reason:");
if (reason == null || reason == '')
return false;
const formData = new FormData();
formData.append('reason', reason);
const comment = parentSelector(event.target, '.comment');
const commentId = comment.getAttribute('data-shortid');
fetchWithCSRF('/comments/' + commentId + '/delete', { method: 'post', body: formData })
.then(response => {
response.text().then(text => replace(comment, text));
});
});
});