I tried to use cakephp default ajax pagination, it seems not working with me. I tried with different way.
The following code using for pagination.
<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>
Now below that code I used the following java script code
<script> $(document).ready(function(){ $(".paginator a").click(function(){ $("#updated_div_id").load(this.href); return false; }) }); </script>
Here, I just fire an event on click under paginator div, once you click on a link under that div, it fetch the url (this.herf) and calling page using ajax, You must prepared the controller for ajax based.
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")); }
Its work for me 🙂
I currently am using standard pagination with the cakephp pagination helper but was interested in ajax based pagination. The only question I have is what does this do for crawlers and SEO? Is google’s crawler smart enough to follow javascript links? TIA
For your information Scott, this method will not affect your SEO,
this method consists of getting the direct link and transform it into an ajax request .
let me explain it . the paginator has direct href links, but with the javascript below, the client will listen if any link found in the paginator class was clicked on, if so then the client will send an ajax request to get the content of the clicked link and update the div with the response .
I’ve just come across with your solution searching to resolve the ajax paginatin in Cakephp 1.3 .
For your solution, it works, but not all the time .
it’s kinda possible, but it won’t work if you have the paginator included in the ajax response
if the jquery is listening on the click event of the pagination div, the pagination div will be reloaded with the ajax response then the clickevent will be ignored … So direct link again 😦 …
great……. it’s working properly…… nice
Reblogged this on Sarwarhossain's Blog and commented:
test
Thanks for your post, It saved me a lot of time and hassle 🙂
Thanks a lot!, this work for me 😀
If I want to add multiple paginations with different controller actions how to call in ctp?
thanks a lot … how to do sorting with ajax pagination..