Created
October 21, 2017 03:51
-
-
Save mashirozx/d13cce9d330b60a73378302672f20d07 to your computer and use it in GitHub Desktop.
comment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--蜜汁Ajax--> | |
<div class="commentshow" id="commentshow"> | |
<div id="loading-comments"><span>Loading...</span></div> | |
<ol class="comments-list"> | |
<?php wp_list_comments('type=comment&callback=weisay_comment&reverse_top_level=1'); ?> | |
</ol> | |
<div class="commentnav"> | |
<?php paginate_comments_links(); ?> | |
<script> | |
//Ajax评论,待优化。。 | |
$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body'); | |
$('.commentnav a').on('click', function(e){ | |
e.preventDefault(); | |
$.ajax({ | |
type: "GET", | |
url: $(this).attr('href'), | |
beforeSend: function(){ | |
$('.commentnav').remove(); | |
$('.comments-list').remove(); | |
$('#loading-comments').slideDown(); | |
$body.animate({scrollTop: $('#comments-title').offset().top - 65}, 800 ); | |
}, | |
dataType: "html", | |
success: function(out){ | |
result = $(out).find('.comments-list'); | |
nextlink = $(out).find('.commentnav'); | |
$('#loading-comments').slideUp('fast'); | |
$('#loading-comments').after(result.fadeIn(500)); | |
$('.comments-list').after(nextlink); | |
$body.animate({scrollTop: $('#comments-title').offset().top - 65}, 800 ); | |
} | |
}); | |
}); | |
</script> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment