Yii Tabx pagination problem

I’m working on a Tax widget and I have pagination in each tab the problem when I m working with pagination the page refresh, and I lose the current tab where I was before same things when I was work with ajax page doesn’t reload I lost the active tab i m working with ajax render via jquery
#My view

<?php 

use yii\widgets\ListView;

use yii\widgets\Pjax;

use yii\widgets\LinkPager ;

use kartik\tabs\TabsX;

$categoriesNames = [];

$items = [];

 Pjax::begin(['id' => 'pjax',

 'enablePushState' => true,  // I would like the browser to change link

 'timeout' => 10000 // Timeout needed

 ]);

 $content= ListView::widget([

  'dataProvider'=>$dataProvider,

  

  'itemView' => function ($model, $key, $index, $widget) {

     return $this->render("_filter_card",['model1' => $model]);

     // or just do some echo

     // return $model->title . ' posted by ' . $model->author;

 }, // this is where you have to specify the view file

 'layout' => '{items}', // here you can specify how the listview should render your custom view file. {items} is the list items and {pager} is the pagination component

  'itemOptions'=>[

    'id'=>'member_tab',

    'tag'=>false, // we don't want the wrapping div for each item

  ],

  

  // itemOptions is the place where we can add Html attribute for the wrapper element

]);

$content1= LinkPager::widget([

  'pagination' => $pages,

 'linkOptions'=>[

    'class'=>"page-link ",

    'style'=>'.prev .disabled{

        content: "";

    }'

 ]

  

]);

$content=$content.$content1;

$label=['Filter by: Price','Popular','Customer rating'];

  for($i=0;$i<3;$i++){

    array_push($items, [

        'label' => $label[$i],

        'id'=>'MyTabs',

        'content' => $content,

        'active' => count($items) == 0

    ]);

  }

echo TabsX::widget([

  "id" => "tabs",

              'position'=>TabsX::POS_ABOVE,

              'align' => TabsX::ALIGN_LEFT,

              'bordered'=>true,

              'encodeLabels'=>false,

              'items' => $items

//              [

//                  [ 'label' => 'One', 'content' => 'Anim pariatur cliche...', 'active' => true ],

//                  [ 'label' => 'Two', 'content' => 'Anim pariatur cliche...', 'headerOptions' => [], 'options' => ['id' => 'myveryownID'], ],

//               ],

              ]);  

  

  $ts = '

  $( document ).ready(function() {

       

     $("li.prev.disabled span").empty();

 

     });

 ';

   $this->registerJs($ts);

 
   Pjax::end() ;

#jquery methode

<?php 



  $filter = '

  $( document ).ready(function() {

      function fetch(){

        var prix = 0;

       

     

     

              

        $.ajax({

            type: "POST",

     

          url: "?r=site/filter&price="+prix

            data: prix,

            dataType: "html",

        

            success: function(data) {

              $("#loaderDiv").hide();

                        $("#some_pjax_id").html(data);

                        //$.pjax.reload({container: "#pjax});

                                                

                     }

        

        });

      }

      

      fetch();

      function fetch1(){

                

       

      var prix=$("input:checkbox:checked").val()

     
        
    
          $.ajax({

            type: "POST",

            url: "?r=site/filter&price="+prix,

            timeout: 10000 ,

            data: prix,

            dataType: "html",

            beforeSend: function() {

              $("#some_pjax_id").html(" ");

              $("#loaderDiv").show();

          },

          success: function(data) {

              $("#loaderDiv").hide();

              $("#some_pjax_id").html(data);

          }

              

        });

        

      }

    $( "input:checkbox" ).click(function() {

        

    

       fetch1();

                        

      });

      

     

       

     });

 ';

   $this->registerJs($filter);
1 Like

Try to load the active tab with JS on page loaded event, if that’s not yet fixed.

well i’ve solved month ago but thank you i appreciate it
part of the solution was with js event

1 Like