Ok here is the basic code. I’m not 100% sure it works but you can debug if you want
// controller
function page($offset = 0)
{
$this->load->model('model');
$this->load->library('pagination');
$config['base_url'] = 'http://example.com/index.php/test/page/';
$config['total_rows'] = $this->model->num_rows();
$limit = 20;
$config['per_page'] = $limit;
$config['num_links'] = 10000; // ridiculous high number to show all the links
$config['full_tag_open'] = '<p id="pagination">';
$config['full_tag_close'] = '</p>';
$this->pagination->initialize($config);
$data['pagination'] $this->pagination->create_links();
$this->load->library('table');
$data['table'] = $this->table->generate($this->model->content($limit,$offset));
$this->load->view('page',$data);
}
function ajax_page($offset = 0)
{
$this->load->library('table');
$this->load->model('model');
$limit = 20;
echo $this->table->generate($this->model->content($limit,$offset));
}
// javascript
$(function(){
// change page to ajax_page in pagination urls
$('#pagination a').each(function(){
var href = $(this).attr('href');
href = href.replace(/page/,'ajax_page');
$(this).attr('href',href);
});
// ajax request
$('#pagination a').click(function(){
$.ajax({
type: "GET",
url: $(this).attr('href'),
success: function(table){
$('table').remove(); // remove content
$('#pagination').after(table); // add content
}
});
return false; // don't let the link reload the page
});
});
// view : page.php
<?php echo $pagination.$content ?>