Skip to content

Instantly share code, notes, and snippets.

@mashirozx
Created October 21, 2017 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mashirozx/d13cce9d330b60a73378302672f20d07 to your computer and use it in GitHub Desktop.
Save mashirozx/d13cce9d330b60a73378302672f20d07 to your computer and use it in GitHub Desktop.
comment
<!--蜜汁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