CodeIgnitor-分页链接未在通过查询更新记录时更新

时间:2019-01-09 16:11:14

标签: jquery ajax codeigniter pagination

我正在使用基于Ajax的CodeIgnitor分页。我在通过CodeIgnitor Query应用此类过滤器后获取记录。

$data["results"] = $this->jobs_model->get_fourteen_jobs($search, $city_filter, $type, $min_salary, $max_salary, $industry, $config["per_page"], $records_from);

现在我正在使用此代码进行分页。

    $config["per_page"] = 14;
    $config['use_page_numbers'] = TRUE;

        $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['first_link'] = false;
        $config['last_link'] = false;
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['prev_link'] = '&laquo';
        $config['prev_tag_open'] = '<li class="prev">';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&raquo';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $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['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';

        $config['num_links'] = 3;

$config["total_rows"] = $this->jobs_model->total_jobs();

        $config['attributes'] = array('onClick' => 'myFunction(event, this)');


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



 $data["links"] = $this->pagination->create_links();

    echo json_encode($data);exit;

现在记录正在更新应用了过滤器后页面没有更新,因此当我们单击多余的页面时,它不会显示记录。我希望必须删除多余的页面。

1 个答案:

答案 0 :(得分:0)

我弄错了。我要对所有要进行分页的工作进行计数,并且每次在此行代码中将所有页面都进行分页时。

$config["total_rows"] = $this->jobs_model->total_jobs();

我只是在其中添加了所有过滤器,它还提供了计数的过滤记录。

$config["total_rows"] = $this->jobs_model->total_jobs($search, $city_filter,
            $type, $min_salary, $max_salary, $industry, $config["per_page"], $records_from);