1

我对 Laravel 和 jQuery 很陌生,所以也许这是一个愚蠢的问题。我被卡住了,我不知道在 jScroll 的 nextSelector 部分写什么。nextSelector 应该包含指向下一页的链接,我正在使用 laravel 的 paginate()。我正在尝试无限滚动帖子。

这是我的 home.blade.php,其中包含 jScroll 的帖子和脚本:

<div class="row scroll">
    <div class="col-lg-9 col-lg-offset-1 col-md-10 col-lg-offset-1 col-sm-10 col-sm-offset-1 col-xs-10 col-xs-offset-1">
        @foreach($posts as $post)
            <div class="panel panel-default ag" id="{{$post->id}}">
                <div class="panel-heading poststyle ">{{ $post->name }}</div>
                <div class="panel-body poststyle">
                    {!! nl2br(e($post->depression)) !!}
                </div>
                <ul class="list-group">
                    <li class="list-group-item"></li>
                    <li class="list-group-item">
                        <button class="btn btn-info btn-xs option1 lc{{$post->id}}" data-idl="l{{$post->id}}" onclick="this.blur();" data-toggle="button" name="options" id="option1" autocomplete="off">
                            <span class="glyphicon glyphicon-thumbs-up"></span>
                        </button>
                        <span class = "poststyle">&nbsp;{{ $post->like }}&nbsp;</span>
                        <button class="btn btn-success btn-xs optionx dc{{$post->id}}" data-idd="d{{$post->id}}" onclick="this.blur();" data-toggle="button" name="options" id="option1" autocomplete="off">
                            <span class="glyphicon glyphicon-thumbs-down"></span>
                        </button>
                        <span class = "poststyle">&nbsp;{{ $post->dislike }}&nbsp;</span>
                    </li>
                </ul>
            </div>
            <br>
        @endforeach
            {!! $posts->render()!!}




    </div>
</div>

<script type="text/javascript">
    $(document).ready(function() {
        $('ul.pagination:visible:first').hide();
        $('.scroll').jscroll({
            loadingHtml: '<div class = "loading">&emsp;&emsp;Loading...</div>',
            debug: true,
            autoTrigger: true,
            nextSelector: '?',
            contentSelector: 'div.scroll',
            callback: function () {
                $('ul.pagination:visible:first').hide();
            }
        });
    });
</script>

这是我使用 paginate() 的控制器:

class NavController extends Controller
{
    public function home()
    {
        $posts=Depress::orderBy('id','DESC')->paginate(5);
        return view('home')->with('posts',$posts);
    }

我已经为我不知道该怎么做的地方(nextSelector)打了一个问号(?)。

有人请帮助我......

4

0 回答 0