Fixed reply-twice bug on submission page.
This commit is contained in:
parent
17217d56c2
commit
db185a9ef2
3 changed files with 18 additions and 4 deletions
|
@ -240,12 +240,24 @@ function post_comment(fullname){
|
|||
try {data = JSON.parse(xhr.response)}
|
||||
catch(e) {console.log(e)}
|
||||
if (data && data["comment"]) {
|
||||
commentForm=document.getElementById('comment-form-space-'+fullname);
|
||||
commentForm.innerHTML = data["comment"].replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, '');
|
||||
let id = fullname.split('_')[1];
|
||||
let name = 'comment-form-space-' + fullname;
|
||||
commentForm = document.getElementById(name);
|
||||
|
||||
// dynamically insert comment into the comments section of the current comment/post
|
||||
let comments = document.getElementById('replies-of-' + id);
|
||||
let comment = data["comment"].replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, '');
|
||||
|
||||
comments.innerHTML = comment + comments.innerHTML;
|
||||
|
||||
bs_trigger(commentForm);
|
||||
|
||||
// remove the placeholder if it exists
|
||||
let placeholder = document.getElementById("placeholder-comment");
|
||||
if(placeholder){
|
||||
// clear out the text-center classes etc.
|
||||
comments.classList.remove('text-center');
|
||||
comments.classList.remove('py-7');
|
||||
placeholder.parentNode.removeChild(placeholder);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -603,6 +603,8 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div id="replies-of-{{c.id}}"></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -516,7 +516,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% if p.replies %}
|
||||
<div class="comment-section">
|
||||
<div class="comment-section" id="replies-of-{{p.id}}">
|
||||
{% with comments=p.replies %}
|
||||
{% include "comments.html" %}
|
||||
{% endwith %}
|
||||
|
@ -559,7 +559,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% elif not p.replies and p.deleted_utc == 0 %}
|
||||
<div class="comment-section text-center py-7">
|
||||
<div class="comment-section text-center py-7" id="replies-of-{{p.id}}">
|
||||
<div class="row no-gutters" id="placeholder-comment">
|
||||
<div class="col">
|
||||
<span class="fa-stack fa-2x text-muted mb-4">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue