我正在尝试将这里找到的无限分页jquery插件( https://github.com/jney/jquery.pageless )实现到我的codeigniter项目中。
我输入的jquery代码与演示页面上的代码相同
$('#results').pageless({ totalPages: 10
, url: '/theurl/index'
, loaderMsg: 'Loading more results'
});我的codeigniter控制器中的代码如下所示
$config['base_url'] = base_url() . 'theurl/index';
$config['total_rows'] = $this->model->record_count();
$config['per_page'] = 20;
$config['uri_segment'] = 3;
// Init the config
$this->pagination->initialize( $config );
// Create pagination
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['results'] = $this->onyafeet->fetch_results($config['per_page'], $page);
$data['links'] = $this->pagination->create_links();
// Load the view and pass through all the data
$this->load->view('theurl/index', $data);当我运行代码并到达页面的底部时,它确实可以工作,但它也会将enter页面加载到它为结果创建的新div中。
任何帮助都将不胜感激。
干杯
发布于 2012-10-23 15:39:21
也许您应该将结果加载到局部视图中,否则您将再次加载整个页面。创建一个局部视图来加载所有数据,然后将局部视图加载到主页中:
$config['base_url'] = base_url() . 'theurl/index';
$config['total_rows'] = $this->model->record_count();
$config['per_page'] = 20;
$config['uri_segment'] = 3;
// Init the config
$this->pagination->initialize( $config );
// Create pagination
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['results'] = $this->onyafeet->fetch_results($config['per_page'], $page);
$data['links'] = $this->pagination->create_links();
// AJAX load:
if ($this->input->is_ajax_request) {
$this->load->view('theurl/partial/ajax_partial',$data);
}
else {
// Load the view and pass through all the data
$this->load->view('theurl/index', $data);
}我认为使用这种方法应该是可行的,局部视图必须只包含您想要显示的正确部分,即包含您希望异步加载的所有内容的div。
https://stackoverflow.com/questions/13025338
复制相似问题