buddypress中活动流页面中的“加载更多”按钮对我无效。如果单击意味着,它会突然消失,但不会加载更多的帖子。
<?php if ( bp_get_activity_count() == bp_get_activity_per_page() ) : ?>
<li class="load-more clear">
<a href="#more"><?php _e( \'Load More\', \'buddypress\' ) ?></a> <span class="ajax-loader"></span>
</li>
<?php endif; ?>
我想通过加载更多按钮加载Facebook之类的活动。因此,我尝试了以下代码片段
buddypress forum // Change:
<li class="load-more">
<a href="#more"><?php _e( \'Load More\', \'buddypress\' ); ?></a>
</li>
//为此:
<?php if ( ! bp_activity_has_more_items() ) : ?>
<script type="text/javascript">
jq(\'.pixelMonitor\').remove();
jq(document).unbind(\'scroll\');
</script>
<?php endif; ?>
//2)在该文件的底部添加:
<div class="pixelMonitor" style="width: 1px; height: 1px; position: fixed; bottom: 0;">
<div id="loadingActivityMessage" style="background-color: white; border-radius: 7px 7px 7px 7px; bottom: 4px; display: none; float: right; height: 16px; padding: 4px 2px 4px 39px; position: fixed; width: 100px;">Loading...</div>
<script type="text/javascript">
/* Auto load more updates at the end of the page when reaching the bottom of the page */
jq(document).ready( function() {
iterationAllowed = true;
function loadActivityOnScroll(){
jq("#loadingActivityMessage").show();
if ( null == jq.cookie(\'bp-activity-oldestpage\') )
jq.cookie(\'bp-activity-oldestpage\', 1, {path: \'/\'} );
var oldest_page = ( jq.cookie(\'bp-activity-oldestpage\') * 1 ) + 1;
jq.post( ajaxurl, {
action: \'activity_get_older_updates\',
\'cookie\': encodeURIComponent(document.cookie),
\'page\': oldest_page
},
function(response){
jq("#loadingActivityMessage").hide();
jq.cookie( \'bp-activity-oldestpage\', oldest_page, {path: \'/\'} );
jq("#content ul.activity-list").append(response.contents);
}, \'json\' );
return false;
};
jq(document).scroll(function(){
if ( Math.round(jq(\'.pixelMonitor\').last().offset().top) > ( jq(document).height() -500 ) && iterationAllowed === true ) {
loadActivityOnScroll();
iterationAllowed = false;
setTimeout(\'iterationAllowed = true\', 3000);
};
});
}); /* Auto load more activity block ending here */
</script>
有人知道这个问题并解决了吗?请
提前谢谢。
<li class="load-more">
<a href="#more"><?php _e( \'Load More\', \'buddypress\' ); ?></a>
</li>
我已经添加了下面的代码,现在当我单击“加载更多”按钮但“加载更多…”时,它可以工作了没有显示!