frankban / django-endless-pagination

This project is deprecated: please use https://github.com/shtalinberg/django-el-pagination
MIT License
251 stars 108 forks source link

When new objects are loaded, it does not appear in the source page. #88

Open robinlery opened 9 years ago

robinlery commented 9 years ago

Suppose a new page is loaded, with one entry (i.e. snapgroup). And I can view the source page which includes that one loaded entry in the html. So when I scroll down, it loads another entry. Now when I view the source page nothing has been changed, and the newly loaded entry is not included in the html, only the first entry exist instead of two entries. However it does display in the browser. And since I am using a lightbox, when I open an image of second entry from the slider it does open the image but if I click next, it starts displaying the images only from the first entry. What's going on?

I came across this question, but both our questions are different. Will someone please help me with this. Thank you.

views.py

def snaps(request,template = 'snaps.html',
                  page_template = 'snapgroups.html' ):

    context = {}    
    snapgroup = SnapGroup.objects.order_by('-date')

    context.update( {'snapgroup': snapgroup, 'page_template': page_template,} )

    # override the template and use the 'page' style instead.
    if request.is_ajax():
        template = page_template

    return render_to_response(
        template, context, context_instance=RequestContext(request) )   

snaps.html:

{% extends "base.html" %}

{% block main_content %}
<div id="main_content">
    <div id="snap_wrapper" class="container">
        <hr>
        {% if snapgroup.count > 0 %}

<div class="endless_page_template">
    {% include page_template %}
</div>

{% block js %}
<script src="http://code.jquery.com/jquery-latest.js"></script> 
<script src="{{ STATIC_URL }}endless_pagination/js/endless_on_scroll.js"></script>
<script src="{{ STATIC_URL }}endless_pagination/js/endless-pagination.js"></script>
<script>
    $.endlessPaginate({paginateOnScroll: true,
    endless_on_scroll_margin : 10
});</script>
{% endblock %}           

        {% else %}
            <li><p>No SNAPGROUP yet!</p></li>
            <span class="clear_both"></span>
        {% endif %}

    {% load disqus_tags %}
    {% disqus_show_comments %}

    </div>

</div>
{% endblock %}

snapgroup.html:

{% load endless %}

{% paginate 1 snapgroup %}

{% for sg in snapgroup %}
    <h4 id="combination" class="snap_date">{{sg.date|date:'l'}}, {{sg.date}}</h4>
    <ul>
    {% for snap in sg.snap_set.all %}
        <li><a href="{{MEDIA_URL}}{{snap.image}}" data-imagelightbox="f"><img src="{{MEDIA_URL}}{{snap.image}}" alt="{{snap.caption}}" /></a></li>
    {% endfor %}
        <span class="clear_both"></span>
    </ul>
{% endfor %}

{% show_more "more..." "working" %}