Guest User

buddypress activity stream - Load More

a guest
Jul 29th, 2014
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. /* Load more updates at the end of the page */
  2. if ( target.parent().hasClass('load-more') ) {
  3. jq("#content li.load-more").addClass('loading');
  4.  
  5. if ( null == jq.cookie('bp-activity-oldestpage') )
  6. jq.cookie('bp-activity-oldestpage', 1, {
  7. path: '/'
  8. } );
  9.  
  10. var oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1;
  11.  
  12. var just_posted = [];
  13.  
  14. jq('.activity-list li.just-posted').each( function(){
  15. just_posted.push( jq(this).attr('id').replace( 'activity-','' ) );
  16. });
  17.  
  18. jq.post( ajaxurl, {
  19. action: 'activity_get_older_updates',
  20. 'cookie': bp_get_cookies(),
  21. 'page': oldest_page,
  22. 'exclude_just_posted': just_posted.join(',')
  23. },
  24. function(response)
  25. {
  26. jq("#content li.load-more").removeClass('loading');
  27. jq.cookie( 'bp-activity-oldestpage', oldest_page, {
  28. path: '/'
  29. } );
  30. jq("#content ul.activity-list").append(response.contents).trigger('post-load');
  31.  
  32. target.parent().hide();
  33. }, 'json' );
  34.  
  35. return false;
  36. }
  37. });
Add Comment
Please, Sign In to add comment