Using default pagination helper in cakephp.
<div class="paginator">
<?php echo $paginator->first(' First ', null, null, array('class' => 'disabled')); ?>
<?php echo $paginator->prev('Previous ', null, null, array('class' => 'disabled')); ?>
<?php echo $paginator->numbers(); ?>
<?php echo $paginator->next(' Next ', null, null, array('class' => 'disabled')); ?>
<?php echo $paginator->last(' Last ', null, null, array('class' => 'disabled')); ?>
</div>
Below is the javascript code.
<script>
$(document).ready(function(){
$(".paginator a").click(function(){
$("#updated_div_id").load(this.href);
return false;
})
});
</script>
Once you click on a link under that div, it fetch the url (this.herf) and calling page using ajax.
For example your controller calling ajax_pages action.
function ajax_pages(){
$this->layout = 'ajax';
$this->paginate = array(
'order' => array('Module.created_date' => 'desc'),
'recursive' => -1,
"limit" => PAGINATION_LIMIT
);
$conditions['Module.module_type'] = $module_type;
$data = $this->paginate("Module", $conditions);
$this->set(compact("data"));
}
0 Comment(s)