Return to Snippet

Revision: 18549
at October 2, 2009 00:00 by dsntos


Initial Code
/* Ajax pages */
    
    if ($("span.curr_page").length) {
        $("#loader").show();
    }
    pulling = false;

    function grabPage(next_page) {
        if (next_page && pulling == false) {
            pulling = true;
            $.get(next_page,

            function(data) {
                var pages = data.split("<!--PAGES-->");
                var new_pages = pages[1];

                var posts = data.split("<!--POSTS-->");
                var new_posts = posts[1];
                $("div.post:last").after(new_posts);
                $("div#pagination").html(new_pages);
                pulling = false;
            });
        }
    }

    $(window).scroll(function() {
        var currpos = 0.8*($(document).height() - $(window).height());

        if ($("span.curr_page").length && $("#older").length) {
            if ($(window).scrollTop() > currpos) {
                grabPage($("#older").attr("href"));
            }
        } else {
            $("#loader").hide();
        }
    });

Initial URL
http://pastie.org/608232

Initial Description

                                

Initial Title
Auto-pager scroll

Initial Tags

                                

Initial Language
jQuery