1
私はこのテーブルのテーブルとページ番号を持つビューを持っていますが、ページを使用するとビューが複製されます。 Laravel - ページネーションがうまくいきません
私のコントローラ機能:public function index()
{
$items = Items::where('active', '=', 1)->paginate(5);
if (Request::ajax())
{
return View::make('app/items.index')->with('items', $items)->render();
}
else
{
return view('app/items.index', array('items' => $items));
}
}
私のjQuery:
function pagination()
{
$(document).on("click", ".pagination a", function(e)
{
e.preventDefault();
alert($(this).attr('href'));
$.ajax({
url: $(this).attr('href'),
})
.done(function(data)
{
console.log(data);
$('#listSearchItems').html(data);
});
});
}
私の見解:
@section('content')
<div class="header"></div>
<div id="listSearchItem" class="content">
<table>
</table>
@if($items->render())
<nav class="pagination">
<a href="{{$items->previousPageUrl()}}">
<i class="material-icons">arrow_back</i>
</a>
<a href="{{$items->nextPageUrl() }}">
<i class="material-icons">arrow_forward</i>
</a>
</nav>
@endif</div>@stop
と私は改ページボタンでクリックしたときに、ビューのコードは、すべての中に重複していますテーブル情報は更新されますが、ビューの既存のHTMLもすべて追加され、コードが複製されます。
誰でも手伝ってもらえますか?私はすでにこの問題について多くのことを探していますが、コントローラーの情報を返す方法がわからないのです。
ありがとうございました