diff options
Diffstat (limited to 'static/js/controllers/replies_controller.js')
-rw-r--r-- | static/js/controllers/replies_controller.js | 11 |
1 files changed, 9 insertions, 2 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) { |