laravel数据分页不起作用

时间:2018-01-19 04:50:18

标签: php jquery datatables blade

我在laravel中使用数据表,但分页不起作用。当我在表中添加静态数据时,它正在工作。我可以知道我错过了什么或者它不工作的原因吗?提前谢谢。

@section('content')


<div class='panel panel-default'>
   <div class='panel-body'>
    <table id ="allPostTable">
    <thead>
        <tr>
          <th>S.No.</th>
          <th>Title</th>
          <th>Category</th>
           <th>Author Name</th>
          <th>Date</th>
          <th>Share</th>
          <th>Action</th>
        </tr>
      </thead>
      <tbody>
       @foreach($posts as $post)
        <tr> 
          <td>{{ $post->id }}</td>
              @if(strlen ($post->post_title)  > 0)
                <td>{{$post->post_title}}<br>{{ $post->p_post_title }} </td>
              @else
                <td><a href="{{ url('posts/' . $post->id . '/edit') }}" class="btn-primary btn-xs">Edit</a></td>
              @endif
            <td>{{ $post->category->category or '' }}</td>
           <td>{{$post->post_author}}</td>
          <td>{{$post->created_at}}</td>
            <td></td>
          <td><a href="{{ url('posts/' . $post->id . '/edit') }}" class="btn btn-primary btn-xs">Edit</a>
            <a href="{{ url('posts/' . $post->id) }}" class="btn bg-orange btn-xs">View</a></td>
        </tr>
        @endforeach
      </tbody>
    </table>
    </div>
  </div>
</div>
@stop
@section('script')

javaScript代码:

  @section('script')
    <!-- data tables -->
    <script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
    <script>

        $('#allPostTable').DataTable( {
          "paging": true, 
          "sPaginationType": "full_numbers",
        } );
    </script>
    @stop

0 个答案:

没有答案