Skip to content

briandonahue/jquery-infinity-scroll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

jQuery Infinity Scroll

Yet another infinite scroll plugin… Initially inspired by https://github.com/brianmario/jquery-infinite-scroll

Goals

  • Deal in JSON, don’t ask ajax requests to return HTML
  • Be templating/rendering agnostic – plug in your own function to handle returned data
  • Allow for flexible callbacks, with or without custom params
  • Follow jQuery plugins as close as possible (and as best I understand them!)

Caveats

  • Currently the plugin assumes you are scrolling the document, it doesn’t handle other DOM element scrolling (scrolling
  • DIVs, etc), though it should be trivial to add.
  • I’m sure there is more that can be done to clean up and conventionalize. It’s my first plugin, pulled from my own project.

Usage

 $('tbody.someTableBody').infinityscroll(
    {
      url: "http://somewhere.com/list",
      triggerAt: 50, // pixels from bottom of rendered list
      resultsPerPage: 50,
      appendTo: $('tbody.someTableBody'), // could technically append to different DOM object, not sure this is
necessary
      params: { userId: 5, otherInfo: 'test' },
      renderData: function(data, element){ /* do stuff to render JSON to your element */ },
      error: function () { /* handle ajax error */ },
      loadOnInit: false // opt out of auto-loading so we can control when it first loads, by calling $element.infinityscroll('reset')
    });

About

Infinite Scroll plugin for jQuery

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published