samedi 2 juillet 2016

What to write in nextSelector of jScroll for infinite scrolling with laravel 5 pagination?

I am quite new to Laravel and jQuery, so maybe this is a silly question. I am stuck and I don't know what to write in the nextSelector section of jScroll. nextSelector is supposed to contain the link to the next page, and I am using paginate() of laravel. I am trying to get infinite scrolling for the posts.

This is my home.blade.php which contains the posts and the script for 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="">
                <div class="panel-heading poststyle "></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" data-idl="l" onclick="this.blur();" data-toggle="button" name="options" id="option1" autocomplete="off">
                            <span class="glyphicon glyphicon-thumbs-up"></span>
                        </button>
                        <span class = "poststyle">&nbsp;&nbsp;</span>
                        <button class="btn btn-success btn-xs optionx dc" data-idd="d" onclick="this.blur();" data-toggle="button" name="options" id="option1" autocomplete="off">
                            <span class="glyphicon glyphicon-thumbs-down"></span>
                        </button>
                        <span class = "poststyle">&nbsp;&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>

This is my controller where I have used paginate():

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

I have put a question mark (?) for the place where I don't know what to do (nextSelector).

Someone please help me.....



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire