I use pagination in rails3 using kaminari stone.
I followed this code from github https://github.com/amatsuda/kaminari_example/commits/ajax
unfortunately the following code
jQuery ('# paginator'). html ('<% = escape_javascript (paginate (@recipes,: remote => true) .to_s)%>');
doesn't seem to work.
my javascript for what to do, what the user chooses for the page,
jQuery ('a', 'nav.pagination'). click (function () {
// get the page value from href
var page = jQuery (this) .attr ('href'). replace ('/ home / index? page =', '');
jQuery.getJSON ('? page =' + page, function (data) {
for (var r in data) {
results.push (data [r]);
});
showResults (results, (page-1) * 10);
jQuery ('# paginator'). html ('<% = escape_javascript (paginate (@recipes,: remote => true) .to_s)%>');
});
The showResults function is launched via JSON and creates a bunch of html elements. Everything works just fine, except that pagination does not refresh to show the current page when the results are reloaded.
I have no errors in firebug, I use Rails 3 with ruby ββ192.
source share