I'm following a guide on how to make the pagination with Ajax, but i'm, having a two problems:
The list are first showing up after i click, on one of the links() in the pagination.
The pagination's links() dosn't move it's just on one, all the time but the information are changing. I've tried a couple of diffrent things, but here are my latest try. (I'm trying to show the tasks assigned to a user, on the users page.)
The scipt on Users show page
<script>
// Ajax pagination
$(document).on('click', '.pagination a', function (e) {
e.preventDefault();
var page = ($(this).attr('href').split('page=')[1]);
getTasks(page);
});
function getTasks(page) {
console.log('Tasks page =' + page);
$.ajax({
url: '/rockcrm/public/ajax/tasks/test?page=' + page
}).done(function(data) {
$('.clients').html(data);
});
}
</script>
Tasks/test.blade.php
<table class="table table-hover sortable">
<h3>Open tasks ({{$user->tasksAssign->count()}})</h3>
<thead>
<thead>
<tr>
<th>Title</th>
<th>Created at</th>
<th>Deadline</th>
</tr>
</thead>
<tbody>
</tbody>
{!! $tasks->links()!!} //This is the one im click to make the data appear
And last the Route
Route::get('/ajax/tasks/test', function ()
{
$user = User::with('tasksAssign')->firstOrFail();
$tasks = $user->tasksAssign()->paginate(2);
return view('tasks.test', compact('user', 'tasks'))->render();
});
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1PjFgxR
via IFTTT
Aucun commentaire:
Enregistrer un commentaire