pagination-ajax.blade.php
3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<div class="mt-2 text-left">
从 <b>{{$paginator->firstItem()}}</b> 到 <b>{{$paginator->lastItem()}}</b> ,总共 <b>{{$paginator->total()}}</b> 条
<ul class="pagination pagination-sm float-right">
{{-- <li class="pagination-jump ">
<input type="number" class="page-input-ajax" value="1">
</li>
<li class="page-go">
<a class="jump-go page-link" href="javascript:jumpAjax();">跳转</a>
</li>
--}}
@if ($paginator->onFirstPage())
<li class="page-item disabled"><span class="page-link">«</span></li>
@else
<li class="page-item"><a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a></li>
@endif
@foreach ($elements as $element)
@if (is_string($element))
<li class="page-item disabled"><span class="page-link">{{ $element }}</span></li>
@endif
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<li class="page-item active"><span class="page-link">{{ $page }}</span></li>
@else
<li class="page-item"><a class="page-link" href="{{$paginator->url($page)}}">{{ $page }}</a></li>
@endif
@endforeach
@endif
@endforeach
@if ($paginator->hasMorePages())
<li class="page-item"><a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">»</a></li>
@else
<li class="page-item disabled"><span class="page-link">»</span></li>
@endif
</ul>
</div>
<script>
/*function page(url) {
layer_loading();
$.ajax({
type:"get",
url: url,
success:function(msg){
$(".modal-body #pagination-ajax-box").html("");
if(msg){
$(".modal-body #pagination-ajax-box").html(msg)
}
layer_loading_close();
},
error:function (request) {
layer_loading_close();
}
})
}*/
function jumpAjax(){
let fullUrl = "{{request()->fullUrl()}}";
let url = "{{request()->url()}}";
let para = fullUrl.replace(url, '');
console.log(fullUrl)
console.log(url)
let lastPage = {{$paginator->lastPage()}};
let path = "{{$paginator->path()}}";
{{--let query = {{$paginator->getQuery()}};--}}
let page = $(".page-input-ajax").val();
if (page < 0) {
page = 1;
} else if(page > lastPage) {
page = lastPage;
}
if (!para) {
para += "?";
}
para.replace('&', '&');
path += para + "&page="+page
path = htmlDecode(path);
layer_loading();
$.ajax({
type:"get",
url: path,
success:function(msg){
$(".modal-body #pagination-ajax-box").html("");
if(msg){
$(".modal-body #pagination-ajax-box").html(msg)
}
layer_loading_close();
},
error:function (request) {
layer_loading_close();
}
})
// console.log(path);
// window.location.href = path
// $.pjax({container:'#pagination-ajax-box', url: path});
}
function htmlDecode(value){
return $('<div/>').html(value).text();
}
</script>
<style>
.pagination-jump .page-input-ajax {
padding: 4px 0px 3px 8px;
border: 1px solid #dee2e6;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
width: 60px;
text-align: center;
border-right: none;
}
</style>