gpt4 book ai didi

javascript - 银纹 + 无限 Ajax 卷轴 : None Left keeps being added to page

转载 作者:行者123 更新时间:2023-11-28 10:13:44 25 4
gpt4 key购买 nike

我在 silverstripe 网站上运行了无限的 ajax 滚动。我还运行了“NoneLeft”扩展,让人们知道,他们到达了底部。

IAScroll 在 ArticleHolder 页面中显示 ArticlePages,并按其应有的方式显示“NoneLeft”文本。现在,当我直接只显示一个 ArticlePage(周围没有 ArticleHolder)时,它也会显示“NoneLeft”文本。有没有办法关闭它或限制到某个页面?还是我必须解除 ias 与 jQuery 的绑定(bind)?非常感谢

Silverstripe ArticleHolder.php

<?php
class ArticleHolder extends Page {
private static $allowed_children = array('ArticlePage');
}

class ArticleHolder_Controller extends Page_Controller {

public function PaginatedArticles(){
$paginatedItems = new PaginatedList(ArticlePage::get()->sort("Date DESC"), $this->request);
$paginatedItems->setPageLength(4);
return $paginatedItems;
}
}

脚本.js

var ias = jQuery.ias({
container: '#posts',
item: '.post',
pagination: '#pagination',
next: '.next',
delay: 0,
negativeMargin: 250,
history: true; }
});

// Adds a text when there are no more pages left to load
ias.extension(new IASNoneLeftExtension({
text: "You reached the end"
}));

#pagination 的 html 输出,当存在多个帖子时

<div id="pagination" class="line" style="display: none;">
<div class="unit size1of4 lineLeftRight lineLeft">
<p></p>
</div>
<div class="unit size1of4 lineLeftRight lineLeft">
<p> …
<a class="next" href="?start=4"> Next
</a>
</p>
</div>
<div class="unit size1of4 lastUnit lineLeftRight lineRight">
<p></p>
</div>
</div>

当只有一篇文章时,没有#pagination 而是“NoneLeft”文本

<div id="ias_noneleft_1403162234904" class="ias-noneleft line">
<div class="unit size1of4 lineLeftRight lineLeft">
<p></p>
</div>
<div class="unit size2of4 lineMiddle">
<p>
You reached the end
</p>
</div>
<div class="unit size1of4 lastUnit lineLeftRight lineRight">
<p></p>
</div>
</div>

最佳答案

好的,我找到了。当显示单个 ArticlePage 时,文章周围仍然有一个 div with class .post

<div class="post line">
// the article
</div>

一旦无限 ajax 滚动看到 .post div,它就会添加 noneLeft 文本。将 .post class div 移动到 ArticleHolder 的循环中会有所帮助。

文章持有者.ss

<div id="posts" class="line">
<% loop $PaginatedArticles %>
<div class="post line">
<% include ArticlePage %>
</div>
<% end_loop %>
</div>

关于javascript - 银纹 + 无限 Ajax 卷轴 : None Left keeps being added to page,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24291045/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com