Rob*_*bby 6 javascript django jquery django-templates
我正在django/webfaction上创建一个博客.我hompage当前显示4个员额默认(职位仅限于4 queryset中urls.py).现在,我想在用户到达页面底部后再加载四个帖子,并继续保持这一点,直到达到最后一个帖子.怎么做到这一点?
Ano*_*oop 15
如果您希望将内容加载到文档的最底层,请使用以下代码:
$(window).scroll(function()
{
if($(window).scrollTop() == $(document).height() - $(window).height())
{
// load your content
}
});
Run Code Online (Sandbox Code Playgroud)
如果要在达到底部使用的100像素之前加载内容
var loading= false;
$(window).scroll(function() {
if (!loading && ($(window).scrollTop() > $(document).height() - $(window).height() - 100)) {
loading= true;
// your content loading call goes here.
loading = false; // reset value of loading once content loaded
}
});
Run Code Online (Sandbox Code Playgroud)
你可以尝试这样的事情..
var processScroll = true;
$(window).scroll(function() {
if (processScroll && $(window).scrollTop() > $(document).height() - $(window).height() - 100) {
processScroll = false;
// your functionality here
processScroll = true;
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23047 次 |
| 最近记录: |