function vehicle()
{
if($this->isAdmin() == TRUE)
{
$this->loadThis();
}
else
{
$searchText = $this->input->post('searchText');
$data['searchText'] = $searchText;
//$this->load->library('pagination');
$count = $this->hotel_other_model->vehicle_count($searchText);
$returns = $this->paginationCompress ( "vehicle/", $count, 5);
$data['vehicleRecords'] = $this->hotel_other_model->vehicle_list($searchText, $returns["page"], $returns["segment"]);
$this->global['pageTitle'] = 'CodeInsect : Vehicle Listing';
$this->loadViews("hotel_other/vehicle", $this->global, $data, NULL);
}
}
像这样的视图链接
<div class="box-footer clearfix">
<?php echo $this->pagination->create_links(); ?>
</div>
paginationCompress()函数在这里
function paginationCompress($link, $count, $perPage = 10) {
$config ['base_url'] = base_url () . $link;
$config ['total_rows'] = $count;
//$config ['uri_segment'] = SEGMENT;
$config ['uri_segment'] = 2;
$config ['per_page'] = $perPage;
$config ['num_links'] = 5;
$config ['full_tag_open'] = '<nav><ul class="pagination">';
$config ['full_tag_close'] = '</ul></nav>';
$config ['first_tag_open'] = '<li class="arrow">';
$config ['first_link'] = 'First';
$config ['first_tag_close'] = '</li>';
$config ['prev_link'] = 'Previous';
$config ['prev_tag_open'] = '<li class="arrow">';
$config ['prev_tag_close'] = '</li>';
$config ['next_link'] = 'Next';
$config ['next_tag_open'] = '<li class="arrow">';
$config ['next_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 ['last_tag_open'] = '<li class="arrow">';
$config ['last_link'] = 'Last';
$config ['last_tag_close'] = '</li>';
$this->pagination->initialize ( $config );
$page = $config ['per_page'];
$segment = $this->uri->segment (2);
return array (
"page" => $page,
"segment" => $segment
);
}
请为此提供帮助 再次感谢提前 抱歉我的英文不好
答案 0 :(得分:0)
此代码中包含搜索功能,以使搜索和分页同时工作,视图文件末尾有jQuery代码。
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('ul.pagination li a').click(function (e) {
e.preventDefault();
var link = jQuery(this).get(0).href;
var value = link.substring(link.lastIndexOf('/') + 1);
jQuery("#searchList").attr("action", baseURL + "userListing/" + value);
jQuery("#searchList").submit();
});
});
</script>
请检查代码。
jQuery("#searchList").attr("action", baseURL + "userListing/" + value);
您需要提供路线,而不是userListing
。然后它将起作用。