0

我在 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;
    }   
}

脚本.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>
4

1 回答 1

0

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

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

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

文章持有人.ss

<div id="posts" class="line">
        <% loop $PaginatedArticles %>
            <div class="post line">
            <% include ArticlePage %>
            </div>
        <% end_loop %>
</div>
于 2014-06-19T09:16:20.633 回答