【发布时间】:2014-06-18 16:48:00
【问题描述】:
我在 silverstripe 网站上运行了无限的 ajax 滚动。我还运行了“NoneLeft”扩展程序让人们知道,他们到达了底部。
IAScroll 在 ArticleHolder 页面中显示 ArticlePages 并按应有的方式显示“NoneLeft”文本。现在,当我直接只显示一个 ArticlePage(周围没有 ArticleHolder)时,它也显示了“NoneLeft”文本。 有什么办法可以将其关闭或限制到某个页面? 还是我必须从 jQuery 中取消绑定 ias? 非常感谢
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;
}
}
script.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>
【问题讨论】:
-
听起来像是一个javascript问题,而不是silverstripe或php问题。或者它是否可以在后端使用不同的 php 脚本?
-
@Zauberfisch 你的意思是,javascript 触发无限 ajax 滚动一次太多了?
-
idk,我不熟悉你使用的那个无限滚动插件。我只是说,看起来错误在 javascript 中的某个地方。因为它似乎正确地检测到没有更多记录,但它无法拒绝进一步加载。 (由于这一切都发生在前端,php 或 silverstripe 无能为力)
-
你能分享你
#pagination的html输出吗? -
@3dgoo 我已经添加了#pagination的html输出
标签: javascript php css silverstripe jquery-ias