Reloading comment list via event 'pillar:comment-posted' on body element.

This commit is contained in:
2016-11-02 16:11:31 +01:00
parent 80601f75ed
commit 4ec3268a23
2 changed files with 16 additions and 10 deletions

View File

@@ -101,19 +101,23 @@ script.
}
})
.done(function(comment_node_id) {
{% if show_comments %}
var commentsUrl = "{{ url_for('nodes.comments_for_node', node_id=node_id) }}";
loadComments(commentsUrl)
.done(function() {
$('#' + comment_node_id).scrollHere();
});
{% else %}
// TODO: implement something here
console.log('Comment posted succesfully, reload the page to see it.');
{% endif %}
$button
.removeClass('submitting')
.html('Post Comment');
$('#comment_field').val('');
$('body').trigger('pillar:comment-posted', [comment_node_id]);
});
});
{% if show_comments %}
$('body').on('pillar:comment-posted', function(e, comment_node_id) {
var commentsUrl = "{{ url_for('nodes.comments_for_node', node_id=node_id) }}";
loadComments(commentsUrl)
.done(function() {
$('#' + comment_node_id).scrollHere();
});
});
{% endif %}
/* Edit comment */