codeigniter 3.0.6 pagination active class not changed

44 views
0

I am using ajax pagination using codeigniter
controller File:

public function getpagination(){
    $config = array();
    if(isset($_GET) && isset($_GET['profile'])){
        $proId = filter_input(INPUT_GET, 'profile');
        if(filter_input(INPUT_GET, 'page') == 'undefined' ){
            $page=1; //exit;
        } else {
            $page = filter_input(INPUT_GET, 'page');//exit;
        }
        $config['uri_segment'] = 4;
        $config["num_links"] = 5;    
        $config["base_url"] = base_url()."ajax/getpagination/?profile=".$proId."&page=".$page;
        $config["total_rows"] = $this->ajax_model->count_all($proId);
        $config["per_page"] = 10;
        $config["use_page_numbers"] = TRUE;
        $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['first_link'] = 'First';
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
        $config['prev_link'] = 'prev';
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = 'Next';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['last_link'] = 'Last';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="">';
        $config['cur_tag_close'] = '</a></li>';
        $config['use_page_numbers'] = TRUE;
        $config['page_query_string'] = TRUE;
        $config['reuse_query_string'] = TRUE;


        $this->pagination->initialize($config);


        $config["per_page"]; 
        $start = ($page - 1) * $config["per_page"];//exit;


        $output = array(
           'pagination_link'  => $this->pagination->create_links(),
           'log_records'   => $this->ajax_model->load_calllogs($proId, $config["per_page"], $start)
        );
      echo json_encode($output);
    }
}

this is controller file instead of ‘uri_segment’ i have take by get method all query running fine. and on click pagination link data show perfect but active class remain first page, i.e, ‘1’ is always selected.

and view file are as shown below

View :

<tbody id='log_records'></tbody>
            <tfoot id="pagination_link"></tfoot>

and jquery are as following ajax methode.

<script>
        function load_calllog_page(page){
        var selProfile = this.value;
        //alert(selProfile);
        var as = $('.chosen-select option:selected').val();
        //alert(as);
        $.ajax({
            url:"<?php echo base_url(); ?>ajax/getpagination/?profile="+as+"&page="+page,
            asycn:false,
            type: "GET",
            //data: "profile="+selProfile,
            dataType:"html",
            success: function(data){

                var res = JSON.parse(data); 

                $('#log_records').html(res.log_records);
                $('#pagination_link').html(res.pagination_link);
            }
        });
}



        $(document).on("click", ".pagination li a", function(event){
          event.preventDefault();
          var page = $(this).data("ci-pagination-page");

          load_calllog_page(page);
    });