View on GitHub

Dynapagin

A jQuery plugin for managing client-side pagination.

Download this project as a .zip file Download this project as a tar.gz file

A jQuery plugin for managing client-side pagination. Includes Stylesheet for basic styling, and is completely compatible with Boostrap 3's pagination component.

Usage

<!DOCTYPE html>
<html>
  <head>
    <title>Dynapagin Complete Example</title>
    <link href="stylesheets/style.css" rel="stylesheet" />
  </head>
  <body>
    <div id="dynapagin-example-content"></div>
    <div id="dynapagin-example"></div>

    <script type="application/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="application/javascript" src="js/dynapagin.min.js"></script>
    <script type="application/javascript">
      $(function () { 
        $('#dynapagin-example').dynapagin({
          total: 10
        }, function (page) {
          $('#dynapagin-example-content').html('<em>Page '+page+'</em>!');
        }).on('page', function (event, page) {
          console.log('another way to provide content to page '+page+'.');
        });
      });
    </script>
  </body>
</html>

Prereqs

The Only hard requirement of dynapagin is jQuery. However, you might also want to include some CSS to make the pagination selector presentable.

style.css and style.less

The provided style.css was generated using LESS. The less file has been included in the project for convenience.

Using Bootstrap

Dynapagin is completely compatible with Twitter's Boostrap. If you're using Boostrap dynapagin's selector will inherit the .pagination and .pager styles, including those of their child elements.

Options

Content

Dynapagin provides for an optional callback that will be called on load and when a page change occurs. It recieves as a parameter the number of the page that is expected to be loaded.

Dynapagin also fires off page events that occur when a page change occurs. Just like the callback method the number of the new page passed as a parameter. You can attach an event handler to the dynapagin element for an additional level of control.

License

Dynapagin is licensed under the MIT License. Full text of the license can be read here