Django 中的无限滚动

发布于 2024-12-19 07:59:52 字数 196 浏览 5 评论 0原文

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

我确实研究过 django-endless-pagination 但无法让它工作。有没有什么demo可以让我研究一下?

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.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

揽月 2024-12-26 07:59:52

我们在 www.mymommemories.com 上使用 django 无限分页,没有太多问题。因为我们使用的是 html5media,所以我们必须添加一行来以一秒的延迟运行该函数。 (setTimeOut("html5media()", 1000)。在某些浏览器中无延迟地运行它会导致问题。如果您不使用 html5media,这不应该是一个问题。

模板代码的核心部分。

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

在视图中我们有下面处理ajax请求的

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

page_template不是整个页面,只是与“分页”相关的部分。

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".

许久 2024-12-26 07:59:52

我认为进行无限分页的最简单方法是使用 jQuery(使用 $.loads)。
您甚至不需要更改后端代码。

I thinks the easiest way to do endless pagination is use jQuery (use $.loads).
You even don't need change the back-end code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文