1

"Load-more" button in the activity stream page in buddypress is not working for me. If clicked means , it disappearing suddenly but no more posts are loaded.

<?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> &nbsp; <span class="ajax-loader"></span>
    </li>
<?php endif; ?>

I want to load activities like Facebook or by means of load more button. So I tried the following code snippet got from buddypress forum

    // Change:
<li class="load-more">
    <a href="#more"><?php _e( 'Load More', 'buddypress' ); ?></a>
</li> 

// For this:

<?php if ( ! bp_activity_has_more_items() ) : ?>

    <script type="text/javascript">
        jq('.pixelMonitor').remove();
        jq(document).unbind('scroll');
    </script>

<?php endif; ?>

// 2) Add this at the bottom of that file:

<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>

Does any one got this and get solved? Please ,

Thanks in advance.

<li class="load-more">
    <a href="#more"><?php _e( 'Load More', 'buddypress' ); ?></a>
</li>

I have added back the following code with all and now it s working when I'm clicking the Load more button but the "Loadmore..." is not showing!

closed as off-topic by kaiser Aug 4 '14 at 14:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • @toscho Thank You, for you code formatting .. I too tried it. – user1460692 Jul 27 '12 at 10:10
  • Our editing help is not easy to find … but worth a read. :) I have made a simple cheat sheet that fits into a browser sidebar. – fuxia Jul 27 '12 at 10:21
  • I have added back the following code with all <li class="load-more"> <a href="#more"><?php _e( 'Load More', 'buddypress' ); ?></a> </li> and now it s working when I'm clicking the Load more button but the "Loadmore..." is not showing! – user1460692 Jul 27 '12 at 10:27
0

It needs to be inside a div with id "content" in order to work (check the buddypress global.js file to see why!)

Not the answer you're looking for? Browse other questions tagged or ask your own question.