Add a function to solve the extra input bug when manipulating comments
This commit is contained in:
parent
1d02c1b316
commit
db34fa723a
|
@ -501,6 +501,12 @@ const fetchWithCSRF = (url, params) => {
|
|||
return fetch(url, params);
|
||||
}
|
||||
|
||||
const removeExtraInput = (targetElement) => {
|
||||
// This deletion will resovle a bug that creates an extra hidden input when rendering the comment elements.
|
||||
const extraInput2 = targetElement.parentElement.querySelector('.comment_folder_button');
|
||||
extraInput2.remove();
|
||||
}
|
||||
|
||||
onPageLoad(() => {
|
||||
|
||||
// Global Functions
|
||||
|
@ -586,13 +592,15 @@ onPageLoad(() => {
|
|||
fetch('/comments/' + comment.getAttribute('data-shortid') + '/edit')
|
||||
.then(response => {
|
||||
response.text().then(text => replace(comment, text));
|
||||
});
|
||||
});
|
||||
removeExtraInput(comment);
|
||||
});
|
||||
|
||||
on("click", "a.comment_deletor", (event) => {
|
||||
event.preventDefault();
|
||||
if (confirm("Are you sure you want to delete this comment?")) {
|
||||
const comment = parentSelector(event.target, ".comment");
|
||||
removeExtraInput(comment);
|
||||
const commentId = comment.getAttribute('data-shortid');
|
||||
fetchWithCSRF('/comments/' + commentId + '/delete',{method: 'post'})
|
||||
.then(response => {
|
||||
|
|
Loading…
Reference in New Issue