Friday, July 8, 2022

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

Issue

$('#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.



Answered By - hhff
Answer Checked By - Cary Denson (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.