Laravel and Infinite Scroll

前端 未结 3 1718
小鲜肉
小鲜肉 2020-12-14 04:48

I have a question about laravel pagination and infinite scroll :

First of all, I have this :

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-14 05:05

    There is also a way to implement this with another infinite scroll plugin https://github.com/pklauzinski/jscroll.

    Assuming you have a simple Blade view:

      @foreach($media as $m)
    1. {{$m->title}}
    2. @endforeach
    {{$media->links()}}

    We can achieve infinite scroll with the following JS-code

    jquery.jscroll/jquery.jscroll.min.js');?>
    
    

    The nextSelector property will select the next page link in your default Laravel paging, contentSelector selects only required content, and the callback function hides paging content (I had to manually hide it because their attribute pagingSelector seems to be invalid for me). You can find mode details on plugin's home page.

提交回复
热议问题