I am following the "Pagination with ajax" railscast for my rails 3 application. Everything seems to work great, except the fact that Previous and next links don't work at all.
Basically,
It appears that the previous link is stuck even if I click on other pages, (when I am on the user/show page1)
The "next link" works one time till the page 2 (I can't use it after)
Numbers didn't update when I come to "..."
I would be pleased to know if someone experience the same problem (a bug?) or if my code is wrong. I use will paginate ("~> 3.0.pre2"and jquery 1.8.10) for a list of microposts dependent to users.
Thanks a lot for your help!
here the code:
layout_helper.rb
module LayoutHelper
def javascript(*args)
content_for(:head) { javascript_include_tag(*args) }
end
end
users_controller.rb
def show
@user = User.find(params[:id])
@microposts = @user.microposts.paginate(:per_page => 10, :page => params[:page])
end
microposts/_micropost.html.erb
...
users/show.html.erb
<% javascript "pagination" %>
...
<%= will_paginate @microposts %>
<ul id="feed_items">
<%= render @microposts %>
</ul>
users/show.js.erb
$("#feed_items").html("<%= escape_javascript(render @microposts ) %>");
pagination.js
$(document).ready(function() {
$(".pagination a").live("click", function() {
$.get(this.href, null, null, "script");
return false;
});
});