简体   繁体   English

CodeIgniter / jQuery-分页-无休止的分页

[英]CodeIgniter / jQuery - Pagination - Endless Pagination

Im trying to implement the endless pagination jquery plugin found here ( https://github.com/jney/jquery.pageless ) into my codeigniter project. 我试图将在这里找到的无尽的分页jquery插件( https://github.com/jney/jquery.pageless )实现到我的codeigniter项目中。

The jquery code i enter is the same as whats on the demo page 我输入的jQuery代码与演示页面上的内容相同

$('#results').pageless({ totalPages: 10
, url: '/theurl/index'
, loaderMsg: 'Loading more results'
});

and the code i have in my codeigniter controller is as follows 和我在我的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);

When i run the code, and reach the bottom of the page, it does work, but it also loads the enter page into the new div it creates just for the results. 当我运行代码并到达页面底部时,它确实起作用,但是它也将输入页面加载到仅为结果创建的新div中。

Any help would be greatly appreciated. 任何帮助将不胜感激。

Cheers 干杯

maybe you should load the results into a partial view, because otherwise you're loading again the whole page. 也许您应该将结果加载到局部视图中,因为否则您将再次加载整个页面。 Create a partial view to load all the data, and then, load the partial view into the main page: 创建一个局部视图以加载所有数据,然后将局部视图加载到主页中:

$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);
}

I think that with this approach should work, the partial view must only have the right part that you want to show, the div with all the content you want to load asynchronously. 我认为,采用这种方法应该有效,部分视图必须只包含要显示的正确部分,即div,其中包含要异步加载的所有内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM