Posts Tagged ‘pagination’
AJAX pagination with jQuery and elements
Posted by primeminister | Filed under Cake-Toppings, jQuery/javascript
A simple way to get your paginated data in your view through ajax with jQuery. Thanks to Cesay Dreier and his article at the bakery http://bakery.cakephp.org/articles/view/easy-ajax-pagination-using-jquery.
I changed the code a bit because I use elements in an extensive way. So here is almost the same code but now with an element and some updated javascript code.
I used the latest CakePHP 1.2.5 and did nothing to the layout. So the classes or id’s will be of the default CakePHP layout. I added the blog tutorial posts table and some data.
1. Add to your controller (or AppController):
// my posts controller looks like this
class PostsController extends AppController {
var $name = 'Posts';
var $components = array('RequestHandler');
var $paginate = array('limit' => 10);
function index() {
$this->Post->recursive = 0;
$this->set('posts', $this->paginate());
}
}