From 652934a93c92ae1f1f1df6fa577a1cb78f5b78ff Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Mon, 4 Mar 2024 12:50:17 -0600 Subject: Some improvements to the replies javascript --- static/js/controllers/replies_controller.js | 11 +++++++++-- templates/replies/index.jinja | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/static/js/controllers/replies_controller.js b/static/js/controllers/replies_controller.js index 119062c..45dad24 100644 --- a/static/js/controllers/replies_controller.js +++ b/static/js/controllers/replies_controller.js @@ -12,6 +12,10 @@ export class RepliesController extends BaseController { async init() { this.comment_id = 0; this.reply_form = await this.getReplyForm(); + this.initializeButtons(); + } + + initializeButtons() { this.listenButtons("replies-button", this.renderReplies.bind(this)); this.listenButtons("new-reply-button", this.showReplyForm.bind(this)); } @@ -62,13 +66,16 @@ export class RepliesController extends BaseController { renderSubmitResponse(response_document) { const comment = document.getElementById(`comment-${this.comment_id}`); - const present_replies = comment.querySelector(".replies-section"); + const comment_replies = comment.querySelector(".comment-replies"); + const present_replies = comment_replies.querySelector(".replies-section"); const new_comment_replies = this.htmlFromResponse(response_document).getElementById(`replies-section-${this.comment_id}`) if(present_replies != null) present_replies.replaceWith(new_comment_replies); else - comment.appendChild(new_comment_replies); + comment_replies.appendChild(new_comment_replies); + + this.initializeButtons(); } setCommentId(replies_section) { diff --git a/templates/replies/index.jinja b/templates/replies/index.jinja index eb99464..a3fbb0e 100644 --- a/templates/replies/index.jinja +++ b/templates/replies/index.jinja @@ -6,7 +6,7 @@
{% if reply.author is eq('') %} - Anonymous said: + Anonymous replied: {% else %} {{ reply.author }} replied: {% endif %} -- cgit v1.2.3