Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
Fix | ajax评论回复的bug #13
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingSky-CN committed Jan 12, 2020
1 parent f2f9c3a commit bf0f3fd
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,27 @@ function mdrcd() {
function ac() {
$body = $('html,body');
var g = '.comment-list',
h = '.comment-num',
i = '.comment-reply a',
j = '#textarea',
k = '',
l = '';
h = '.comment-num',
i = '.comment-reply a',
j = '#textarea',
k = '',
l = '';
c();
$('#comment-form').submit(function() {
var ar = $(this).serializeArray();
console.log(ar);
mdui.snackbar({
message: '评论正在发送中...',
position: '<?=$this->options->mdrSnackbar?>',
timeout: 5000
});
});
if (ar[1]['name'] == 'parent') {
l = 'comment-'+ar[1]['value'];
}
$.ajax({
url: $(this).attr('action'),
type: 'post',
data: $(this).serializeArray(),
data: ar,
error: function() {
mdui.snackbar({
message: '提交失败,请检查网络并重试或者联系管理员。',
Expand All @@ -161,7 +166,7 @@ function ac() {
if (l) {
d = $('#comment-' + k, d).hide();
if ($('#' + l).find(".comment-children").length <= 0) {
$('#' + l).append("<div class='comment-children'><ol class='comment-list'><\/ol><\/div>")
$('#' + l).append("<div class='comment-children' style='padding: 0px 8px;'><ol class='comment-list'><\/ol><\/div>")
}
if (k) $('#' + l + " .comment-children .comment-list").prepend(d);
l = ''
Expand All @@ -184,12 +189,12 @@ function ac() {
});
if (k) {
$body.animate({
scrollTop: $('#comment-' + k).offset().top - 50
scrollTop: $('#comment-' + k).offset().top - 72
},
300)
} else {
$body.animate({
scrollTop: $('#comments').offset().top - 50
scrollTop: $('#comments').offset().top - 72
},
300)
}
Expand Down

0 comments on commit bf0f3fd

Please sign in to comment.