Reloading comment list via event 'pillar:comment-posted' on body element.
This commit is contained in:
parent
80601f75ed
commit
4ec3268a23
@ -34,6 +34,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$.fn.scrollHere = function(scroll_duration_msec) {
|
$.fn.scrollHere = function(scroll_duration_msec) {
|
||||||
|
if ($(this).length == 0) return;
|
||||||
|
|
||||||
$('html, body').animate({
|
$('html, body').animate({
|
||||||
scrollTop: this.offset().top
|
scrollTop: this.offset().top
|
||||||
}, scroll_duration_msec);
|
}, scroll_duration_msec);
|
||||||
|
@ -101,19 +101,23 @@ script.
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.done(function(comment_node_id) {
|
.done(function(comment_node_id) {
|
||||||
{% if show_comments %}
|
$button
|
||||||
var commentsUrl = "{{ url_for('nodes.comments_for_node', node_id=node_id) }}";
|
.removeClass('submitting')
|
||||||
loadComments(commentsUrl)
|
.html('Post Comment');
|
||||||
.done(function() {
|
$('#comment_field').val('');
|
||||||
$('#' + comment_node_id).scrollHere();
|
$('body').trigger('pillar:comment-posted', [comment_node_id]);
|
||||||
});
|
|
||||||
{% else %}
|
|
||||||
// TODO: implement something here
|
|
||||||
console.log('Comment posted succesfully, reload the page to see it.');
|
|
||||||
{% endif %}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
{% 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 */
|
/* Edit comment */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user