Fix comment reply

This commit is contained in:
cuom1999 2022-12-23 02:06:44 -06:00
parent 56a9b5d6a0
commit bb58054b77

View file

@ -33,13 +33,20 @@
window.reply_comment = function (parent) { window.reply_comment = function (parent) {
var $comment_reply = $('#comment-' + parent + '-reply'); var $comment_reply = $('#comment-' + parent + '-reply');
var reply_id = 'reply-' + parent; var reply_id = 'reply-' + parent;
var new_id = 'id' + parent + '_body';
if ($comment_reply.find('#' + reply_id).length == 0) { if ($comment_reply.find('#' + reply_id).length == 0) {
var $reply_form = $('#new-comment').clone(true).prop('id', reply_id); var $reply_form = $('#new-comment').clone(true).prop('id', reply_id).css("display", "");
$reply_form.find('h3').html('{{ _('Replying to comment') }}'); $reply_form.find('h3').html('{{ _('Replying to comment') }}');
$reply_form.prepend('<a class="close">x</a>'); $reply_form.prepend('<a class="close">x</a>');
$reply_form.find('form.comment-submit-form input#id_parent').val(parent); $reply_form.find('form.comment-submit-form input#id_parent').val(parent);
$reply_form.find('div#wmd-button-bar-id_body').empty().prop('id','wmd-button-bar-' + new_id);
$reply_form.find('textarea.wmd-input').val('').prop('id', 'wmd-input-' + new_id);
$reply_form.find('div#id_body-preview').attr('data-textarea-id', 'wmd-input-' + new_id).prop('id', new_id + '-preview');
$reply_form.appendTo($comment_reply); $reply_form.appendTo($comment_reply);
register_dmmd_preview($('#' + reply_id + ' #id_body-preview')); register_dmmd_preview($reply_form.find('div#' + new_id + '-preview'));
if ('DjangoPagedown' in window) {
window.DjangoPagedown.createEditor($reply_form.find('div.wmd-wrapper').get(0));
}
} }
$comment_reply.fadeIn(); $comment_reply.fadeIn();