Evooms123's avatar

Problem while using links() and nav tabs : Redirecting to page 2 of other tabs while it does not exist

0

I'm using nav tabs of bootstrap (I have 5 tabs) and paginate function links(). If I have 2 page in the first tab, and I click on next to go to the 2nd page, and then I'm going to another tab, it will be display nothing even if I have data inside it. Why ? Because inside the url, there is the ?page=2 of the 1st tab. It does not erase when I'm changing tabs.

Does someone know how can I be able to resolve this please ?

Example :

<nav class="nav nav-tabs justify-content-center nav-justified">
   <a class="nav-item nav-link active" href="#test1" data-toggle="tab">Test1</a>
   <a class="nav-item nav-link" href="#test2" data-toggle="tab">Test2</a>
 </nav>

Content of the tab pane :

<div class="tab-pane fade show active" id="test1">
   <p>test 1 i'm here</p>
     @foreach($tests as $test1)
         {{ $test1->name }}
     @endforeach
     {!! $tests->links() !!}
 </div>
 <div class="tab-pane fade" id="test2">
    <p>test 2 i'm here</p>
      @foreach($tests as $test2)
         {{ $test2->name }}
     @endforeach
     {!! $tests->links() !!}
  </div>

I have a paginate(1), so if inside my test1 tab, I have more than 1 line (imagine 4), and I go to the page 4, and then I click to the tab test2, it will display that I do not have data even if I have 1 or more (less than 4).

Cordially

0 likes
2 replies

Please or to participate in this conversation.