ajaxdjangopaginationinfinite-scrollzinnia

How to implement infinite scroll, endless pagination using the zinnia blog app from Django


This is my first question here

I want to implement an infinite scrolling (or endless pagination ) on a blog powered by the zinnia app from Django.

My blog structure is the same as zinnia blog, i haven't coded anything different to it. I tried using "django endless pagination" because it's documentation says i can create a twitter style pagination but i couldn't resolve where to put it's snippets of code.

I don't mind if it can be solved by using django endless pagination or not.

My PIP FREEZE looks like this:

Django==1.5.1
Pillow==2.3.1
argparse==1.2.1
beautifulsoup4==4.3.2
django-blog-zinnia==0.13
django-endless-pagination==2.0
django-filebrowser==3.5.6
django-grappelli==2.4.10
django-mptt==0.6.0
django-tagging==0.3.2
django-tinymce==1.5.2
django-xmlrpc==0.1.5
easy-thumbnails==1.3
feedparser==5.1.3
pyparsing==2.0.1
pytz==2014.2
raven==4.2.1
wsgiref==0.1.2

I really appreciate your suggestions.

P.D: Let me know if you need anything else to give an appropriate answer


Solution

  • you can do this in the client side, by using this library : https://github.com/paulirish/infinite-scroll

    Works fine on http://fantomas.willbreak.it/ like this:

    $(document).ready(function () {
        $('.hfeed').infinitescroll({
        navSelector: '.paginator',
        nextSelector: '.paginator .next a',
        itemSelector: '.hentry',
        contentSelector: '.hfeed aside',
        bufferPx: 1000,
        maxPage: 5,
        loading: {
        msgText: '<p>Chargement des articles suivants...</p>',
        finishedMsg: '',
        img: '/static/img/loader.gif',
        },
        }, function (newElements) {
            $(newElements).find('pre').each(function (i, e) {
            hljs.highlightBlock(e)
            });
        });
    });