Search code examples
callbackindexingtumblrinfinite-scrollposts

how to get the index number of my Tumblr posts when in Infinite Scroll


$('#content').infinitescroll({
        binder: $(window),
        debug: true,
        itemSelector : ".post",
        navSelector  : "#pagination",
        nextSelector : "#next-page"

        },function(arrayOfNewElems){  

    });

basically, I want to display the number my Tumblr posts. I have made different attempts but each time the index numbering starts again from 0 after the new content is loaded. How can I make the number a continuation from the previously loaded posts.

what kind of function should i be invoking in

function(arrayOfNewElems){

});

this is the plugin im using

https://github.com/paulirish/infinite-scroll


Solution

  • Just do:

    var totalPosts = null;
    
    $.ajax({
        url: "http://[BLOG NAME HERE].tumblr.com/api/read/json",
        dataType: 'jsonp',
        success: function(results){
            totalPosts = results['posts-total'];
            alert(totalPosts);
        }
    });
    

    Needs jQuery but can be run before the document is loaded.