Django中的无限滚动 [英] Infinite scroll in django

查看:119
本文介绍了Django中的无限滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在向下滚动时实现Facebook样式的内容加载?我想在电子商务网站中实现它.每个类别中都有很多项目,并且类别页面变得太长.我可以实现页码,但是我的客户希望我实现该类型的Facebook加载.有什么我可以使用的吗?该网站的其余部分已经建立.

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 and the category page becomes too long. I could implement page numbers but my client wants me to implement that facebook type of loading. Is there anything I can use? Rest of the site has already been built.

我确实研究了django-endless-pagination,但无法使其正常工作.是否有任何演示,以便我研究?

I did look into django-endless-pagination but was not able to get it to work. Is there any demo of it so that I can look into it?

推荐答案

我们在www.mymommemories.com上使用了django无休止的分页,没有太多问题.因为我们使用的是html5media,所以必须添加一行以延迟一秒钟的时间运行该功能. (setTimeOut("html5media()",1000).在没有延迟的情况下运行它会在某些浏览器中引起问题.如果您未使用html5media,则不必担心.

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.

模板代码的核心部分.

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

在视图中,我们具有以下内容来处理ajax请求.

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))

page_template不是整个页面,而是与分页"相关的部分.

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

这篇关于Django中的无限滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆