From d218bdaac8e5c90a2bd7b7bf428ed09a726102c3 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Fri, 23 Feb 2024 17:18:36 -0600 Subject: Add reply form hiding --- static/js/controllers/replies_controller.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/static/js/controllers/replies_controller.js b/static/js/controllers/replies_controller.js index af0f2ec..5e67057 100644 --- a/static/js/controllers/replies_controller.js +++ b/static/js/controllers/replies_controller.js @@ -22,17 +22,19 @@ export class RepliesController extends BaseController { showReplyForm(event) { const replies_section = event.target.parentElement.parentElement.childNodes[3]; + const form = replies_section.querySelector(".reply-form"); - if(replies_section.querySelector(".reply-form") == null) + if(form == null) replies_section.appendChild(this.reply_form); - /*else hide*/ + else + form.remove(); } showReplies(event) { /* The div to contain the comment's replies. From the element id we can get the comment's id. */ const replies_section = event.target.parentElement.parentElement.childNodes[3]; - const comment_id = /\d/.exec(replies_section.id)[0] + const comment_id = /\d/.exec(replies_section.id)[0]; console.log("You're in showReplies()"); } -- cgit v1.2.3