From 8af020364de534fad66413e8471932a2f777af36 Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 31 Jan 2018 06:56:19 +0100 Subject: [PATCH] Load the comments once they are created. --- assets/js/components/comments/form.js | 35 +++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/assets/js/components/comments/form.js b/assets/js/components/comments/form.js index f54b26a5..a881e4ca 100644 --- a/assets/js/components/comments/form.js +++ b/assets/js/components/comments/form.js @@ -13,12 +13,25 @@ ComunicWeb.components.comments.form = { */ display: function(postID, target){ - //Create form contener - var commentForm = createElem2({ - appendTo: target, - type: "form", - class: "comment-creation-form" - }); + //Check if we are creating a new comment of or reseting an existing one + if(target.className != "comment-creation-form"){ + + //Create form contener + var commentForm = createElem2({ + appendTo: target, + type: "form", + class: "comment-creation-form" + }); + + } + else { + + //Reset current form + emptyElem(target); + var commentForm = target; + + } + //Create input group var inputGroup = createElem2({ @@ -102,7 +115,15 @@ ComunicWeb.components.comments.form = { return; } - //Perform next actions + //Reset the creation form + ComunicWeb.components.comments.form.display(postID, commentForm); + + //Load the new comment before the form element + var newCommentTarget = createElem2({ + insertBefore: commentForm, + type: "div" + }); + ComunicWeb.components.comments.actions.reload(result.commentID, newCommentTarget); });