Search code examples
cakephppaginator

Paginator prev not working with Ajax View


I'm having this issue where the previous button of the paginator is disabled (have disabled class) by default, even if I am in to second or third or any page. If I remove the 'id => prevPage' and 'id => nextPage' then it works fine but I have to use it to make another ajax request.

I'm using this in my ajax view..

echo $this->Paginator->prev('< ' . __('Zur'), array('id' => 'prevPage'), null, array('class' => 'prev disabled'));
echo $this->Paginator->next(__('Vor') . ' >', array('id' => 'nextPage'), null, array('class' => 'next disabled'));

while in my controller, I have;

if($this->RequestHandler->isAjax()) {
$this->autoRender = false;
$this->set('products',$this->paginate('Product'));
$this->set('page',$page);
$this->render('ajaxView');
}

I did a little googling which suggested me it might be bug.. is it? How do I solve?


Solution

  • I wasn't able to find the error, but I fixed the error by going through other way. I was using 'offset' while I was paginating in the controller before which had introduced the error, but using the other way around by requesting to '.../page:3?q=' on the ajax call, did solved the problem. Thanks to @hereshem for the quick fix.