CakePHP

It's a good practice to use inbuilt design component to build our web application. CakePHP offer many inbuilt component as well as helper.
Ajax Pagination is also a great component / helper to build interactive web application.

To implement Ajax Pagination in your application follow these steps:-

Step1:
 Include RequestHandler component and Js helper in your controller.

var $components = array('RequestHandler');
var $helpers = array('Js');

Step 2:
Add JQuery library to your current Layout either javascript or cakephp script tag, if already included skip this step.

echo $this->Html->script('jquery');

Step3:
In your view(ctp) add following line at top most section.

$this->Paginator->options(array(
    'update' => '#content',
    'evalScripts' => true
));

Here we define the div which will update by ajax request and "#content" is id of the div.
Step4:

now add your presentation part in view 
Step 5:
And at last of your view add following line of code to add javascript to call ajax pagination.


echo $this->Js->writeBuffer();

Comments

Popular Posts