我在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>
当只有一篇文章时,没有#分页,但又有“ 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循环中很有帮助。ArticleHolder.ss
<div id="posts" class="line">
<% loop $PaginatedArticles %>
<div class="post line">
<% include ArticlePage %>
</div>
<% end_loop %>
</div>