Infinite scroll in django

后端 未结 3 1707
时光取名叫无心
时光取名叫无心 2021-02-08 09:39

Is it possible to implement facebook style loading of content while scrolling down? I would like to implement it in an ecommerce site. There are a lot of items in each category

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-08 10:17

    We used django endless pagination on www.mymommemories.com without too much problem. Because we were using html5media we did have to add a line to run that function with a one second delay. (setTimeOut("html5media()", 1000). Running it without the delay caused problems in some browsers. If your not using html5media, this should not be a concern however.

    Core part of the template code.

    {% load endless %}
    {% paginate memories %}
    {% for memory in memories %}
    .
    .
    .
    {%  endfor %}
    {%  show_more %}
    

    In the view we have the following to handle the ajax request.

    if request.is_ajax():
        template = page_template
        return render_to_response(template,context,context_instance=RequestContext(request))
    

    The page_template is not the whole page, just the portion related to the "paging".

提交回复
热议问题