我有一个Laravel项目,在userlist.blade.php我有它显示用户列表哪个工作正常,但我使用选择字段将分页限制为不同的值,并在来自Stackoverflow的Nitish Kumar帮助我能够从选择字段中获取值,但我试着知道如何获得值以实现当前分页但我不能不理解事情是如何工作的还在我用于显示用户增量数的循环中的索引不起作用很好的分页所以我真的需要帮助来了解事情是如何工作的。拜托?
userlist.blade.php https://codeshare.io/2KoB4X
UsersController https://codeshare.io/G8rzjB
的script.js https://codeshare.io/5o0pWM
路线 https://codeshare.io/a3opmm
编辑1: 我在下面的链接中寻找的示例有数据表,您可以在其中选择显示条目数以在表中显示结果 https://adminlte.io/themes/AdminLTE/pages/tables/data.html
答案 0 :(得分:0)
这是我目前的代码
$(document).ready(function() {
$('#issueinput5').on('change', function() {
$.ajax({
url:'/lists/user',
method:'POST',
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
data:{'pageinateData':$('#issueinput5').val(),},
success:function(d){
console.log(d)
}
});
});
});
<div class="form-group col-md-5">
<div class="col-md-1">Show</div>
<div class="col-md-2"><select id="issueinput5" name="priority" class="form-control"
data-toggle="tooltip" data-trigger="hover" data-placement="top" data-title="Priority">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select></div>
<div class="col-md-1">entries</div>
</div>
<div class="table-responsive pl-1 pr-1">
<table class="table table-bordered mb-0">
<thead>
<tr>
<th>#</th>
<th>Full Name</th>
<th>Username</th>
<th>Email</th>
<th>User Type</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
<tr>
<th scope="row">{{ $loop->index + 1 }}</th>
<td>{{ $user->fullname }}</td>
<td>{{ $user->username }}</td>
<td>{{ $user->email }}</td>
<td>
@foreach( $roles as $role ) {{ $user->role_id == $role->id ? $role->name : ''}} @endforeach
</td>
<td>
<a href="{{ route('dUseInfo', [$user->id]) }}"><button type="button"
class="btn mr-0 mb-0 btn-outline-primary btn-sm"><i class="icon-settings2"></i> </button></a>
<button type="button" class="btn mr-0 mb-0 btn-outline-primary btn-sm"
data-toggle="modal" data-target="#iconModal" data-user-id="{{ $user->id }}">
<i class="icon-trash3"></i></button>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>