Sep 20, 2022
0
Level 2
Livewire Pagination in same links twice
I'm am using Livewire components in my project. It's working fine in most of area. but when I'm using Livewire pagination. It's showing same link twice.
Please check the screen shot I have provided below. https://prnt.sc/uE4ecmvdQfz9
Here's my Pagination code. Please help
<div>
@if ($paginator->hasPages())
@php(isset($this->numberOfPaginatorsRendered[$paginator->getPageName()]) ? $this- >numberOfPaginatorsRendered[$paginator->getPageName()]++ : $this->numberOfPaginatorsRendered[$paginator->getPageName()] = 1)
<ul class="custom-pagination list-unstyled" role="navigation">
@if ($paginator->onFirstPage())
<li class="disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
<a class="" href="{{ $paginator->previousPageUrl() }}" rel="prev" aria-label="@lang('pagination.previous')"><i class="la la-angle-double-left"></i></a>
</li>
@else
<li class="">
<a wire:click="previousPage('{{ $paginator->getPageName() }}')" wire:loading.attr="disabled" dusk="previousPage{{ $paginator->getPageName() == 'page' ? '' : '.' . $paginator->getPageName() }}.before" >
<i class="la la-angle-double-left"></i>
</a>
</li>
@endif
{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- Array Of Links --}}
@if (is_array($element))
@php
$start = $paginator->currentPage(); // show 3 pagination links before current
$end = $paginator->currentPage() + 4; // show 3 pagination links after current
if($start < 1) {
$start = 1; // reset start to 1
$end += 1;
}
if($end >= $paginator->lastPage() ) $end = $paginator->lastPage(); // reset end to last page
@endphp
@if($start > 1)
<li class="">
<a class="" wire:click="gotoPage({{ 1 }}, '{{ $paginator->getPageName() }}')" aria-label="{{ __('Go to page :page', ['page' => 1]) }}">
{{ 1 }}
</a>
</li>
@if($paginator->currentPage() != 4)
{{-- "Three Dots" Separator --}}
<li class="disabled" aria-disabled="true"><span class="">...</span></li>
@endif
@endif
@for ($i = $start; $i <= $end; $i++)
<li class="{{ ($paginator->currentPage() == $i) ? 'active' : '' }}">
{{-- <a class="" href="{{ $paginator->url($i) }}">{{$i}}</a> --}}
<a class="" wire:click="gotoPage({{ $i }}, '{{ $paginator->getPageName() }}')" aria-label="{{ __('Go to page :page', ['page' => $i]) }}">
{{ $i }}
</a>
</li>
@endfor
@endif
@endforeach
@if ($paginator->hasMorePages())
<li class="">
<a wire:click="nextPage('{{ $paginator->getPageName() }}')" wire:loading.attr="disabled" dusk="nextPage{{ $paginator->getPageName() == 'page' ? '' : '.' . $paginator->getPageName() }}.before">
<i class="la la-angle-double-right"></i>
</a>
</li>
@else
<li class="disabled" aria-disabled="true" aria-label="@lang('pagination.next')">
<a class="">
<i class="la la-angle-double-right"></i>
</span>
</li>
@endif
</ul>
@endif
</div>
Please or to participate in this conversation.