I am trying to implement continuous pagination on scroll using django-endless-pagination.
The initial rendering of the page works fine. Once scrolled, however, the entire html page contents are loaded into the endless_page_template div, rather than the desired partial html content from the page_template. The result is sort of like looking into a mirror that is reflecting another mirror behind it. I believe that the queryset returned is correct because the pagination results are correct when not attempting to use "paginateOnScroll".
The relevant parts of my view are below. I'm using a CreateView because I have the comments form on the same page as the paginated comments.
class MyIndex(CreateView):
form_class = CommentForm
template_name = 'my/index.html'
page_template = 'my/comments.html'
def get_context_data(self, **kwargs):
context = super(MyIndex, self).get_context_data(**kwargs)
context.update({
'comments': Comment.objects.order_by('-id').filter(parent=None),
'page_template': self.page_template,
})
return context
The relevant parts of my/index.html template (main template)
<script src="{% static 'endless_pagination/js/endless-pagination.js' %}"></script>
<script type="text/javascript">
$.endlessPaginate({
paginateOnScroll: true
});
</script>
<div class="endless_page_template">
{% include page_template %}
</div>
The relevant parts of my/comments.html (page_template)
{% load endless %}
{% paginate comments %}
{% for comment in comments %}
<span class="lead">{{ comment.name }}</span>
{{ comment.message}}
{% if not forloop.last %}
<hr />
{% endif %}
{% endfor %}
<br />
<div class="row-fluid">
<div class="span8 offset2 pagination-centered">
{% show_more %}
</div>
</div>
Thanks!