Skip to content
Infinite Scroll plugin for jQuery
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitignore
README.textile
jquery.infinity-scroll.js

README.textile

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')
    });
Something went wrong with that request. Please try again.