Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. // unbind normal behavior. needs to occur after normal infinite scroll setup.
  2. $(window).unbind('.infscr');
  3. // call this whenever you want to retrieve the next page of content
  4. // likely this would go in a click handler of some sort
  5. $(document).trigger('retrieve.infscr');
  6.  
  7. <div id="items">
  8. <!-- Run your query using the page parameter to offset items, then display the items here -->
  9. </div>
  10. <button id="more">More</button>
  11.  
  12. var page = 0;
  13. $('#more').click(function(){
  14. page++;
  15. $('<div/>').appendTo('#items').load('the/same/url/?page='+page+' #items');
  16. });
  17.  
  18. $('.container').infinitescroll({
  19. // infinite scroll options
  20. },
  21. function(){
  22. // pause when new elements are loaded
  23. $('.container').infinitescroll('pause')
  24. }
  25. );
  26.  
  27. function resume_infinite_scroll(){
  28. // resume
  29. $('.container').infinitescroll('resume')
  30. // check if new elements should be loaded
  31. $('.container').infinitescroll('scroll')
  32. }
  33.  
  34. <button onclick="resume_infinite_scroll()">load more</button>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement