Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (41 sloc) 1.44 KB

Scroll Pagination Utility

A JavaScript utility for creating infinite scrolling.


Includes the following files.

<link rel="stylesheet" href="assets/scroll-pagination.css">
<script type="text/javascript" src=""></script>
<script type="text/javascript" src="scroll-pagination.js"></script>


YUI().use("scroll-pagination", function (Y) {

    var scroll = new Y.ScrollPagination({
        data: {
            source: "ajax.php", // API Entrypoint.
            schema: {
                metaFields: { // Your data schema for JSON. You can customize for your need.
                    count: "result.count",
                    last_id: "result.last_id",
                    last_timestamp: "result.last_timestamp",
                    html: "result.html"
            request: "?page=1&r=" + parseInt(new Date().getTime(), 10) // Upcoming API request.

    scroll.on("load", function (e) {
        // Set for next request.
        self.set("data.request", [
            "?last_id=" + data.last_id,
            "&last_timestamp=" + data.last_timestamp,
            "&page=" + page
        // Inject HTML."#foo").append(data.html);


API Documentation

Something went wrong with that request. Please try again.