Files
nairobi/app/views/comments/create.js.erb
Senén Rodero Rodríguez 956f002738 Update parent comment responses count when a new reply is created
Extract the needed portion of code to a new partial to be able to update
only the elements needed when a new comment is added keeping UI properly
updated.
2020-05-26 13:20:26 +02:00

11 lines
433 B
Plaintext

<% if @comment.root? -%>
var parent_id = "";
<% else -%>
var parent_id = "#" + "<%= "comment_#{@comment.parent_id}" %>";
var responses_count_html = "<%= j(render "comments/responses_count", count: @comment.parent.children.size) %>"
App.Comments.update_responses_count(parent_id, responses_count_html);
<% end -%>
App.Comments.reset_form(parent_id);
App.Comments.add_comment(parent_id, "<li><%= j(render @comment) %></li>");