Update comments count when commenting on a debate or proposal

This commit is contained in:
Sergio Arbeo
2015-10-27 01:02:39 +01:00
parent 912deb38b2
commit 12ec1fe6f6
5 changed files with 11 additions and 2 deletions

View File

@@ -2,9 +2,16 @@ App.Comments =
add_comment: (parent_id, response_html) ->
$(response_html).insertAfter($("#js-comment-form-#{parent_id}"))
this.update_comments_count()
add_reply: (parent_id, response_html) ->
$("##{parent_id} .comment-children:first").prepend($(response_html))
this.update_comments_count()
update_comments_count: (parent_id) ->
$(".js-comments-count").each ->
new_val = $(this).text().trim().replace /\d+/, (match) -> parseInt(match, 10) + 1
$(this).text(new_val)
display_error: (field_with_errors, error_html) ->
$(error_html).insertAfter($("#{field_with_errors}"))