Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

will_paginate find out if I'm on the last page

I'm trying to use will paginate with ajax, but I don't show the will_paginate buttons... instead I use a see more button, that makes an Ajax request and append the results to the page. what I'm trying to do is disable this see more button if I hit the last page of records!! Any idea how to know that the current page is the last page??

like image 341
zeacuss Avatar asked May 22 '12 09:05

zeacuss


3 Answers

@collection.total_pages == @collection.current_page
like image 182
Alexandr Yakubenko Avatar answered Nov 07 '22 23:11

Alexandr Yakubenko


Accessing the @collection.total_pages method will give you the total number of pages currently being returned. You can use this to evaluate against your active page using the @collection.current_page method. This is still applicable if you're reloading your collection on each expansion.

The implementation will be to use the AJAX call to replace the HTML content if this evaluation is true.

like image 43
nickpellant Avatar answered Nov 08 '22 00:11

nickpellant


You can use next_page condition

@collection.next_page.present?
like image 26
Marcelo Austria Avatar answered Nov 08 '22 00:11

Marcelo Austria