I'm implementing pagination in rails3 using the kaminari gem.
I've been following 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) %>');
does not seem to be working.
my javascript for what to do what a user selects a page is
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 runs through the JSON and creates a bunch of html elements. Everything is working great, except that the pagination isn't updating to show the current page when the results are reloaded.
I don't get any errors in firebug, i'm using Rails 3 with ruby 192.