I'm trying Ajax Will Paginate plugin. For further info click here.
My view's code is:
<h4>Top Ten</h4>
<div id="top_ten_results">
<p>
<table border="0">
<% unless @top_ten_posts.nil? %>
<% @top_ten_posts.each do |p| %>
<tr>
<td><%= link_to p.title, p %></td>
</tr>
<tr>
<td><%= link_to 'Comments', post_comments_path(p.id) %> | created by <%= link_to p.user.login, profile_path(p.user_id) %> | <%= p.created_at %></td>
</tr>
<tr>
<td><%= render :partial => '/users/vote_post', :object => p.id %></td>
</tr>
<tr>
<td> </td>
</tr>
<% end %>
<% end %>
</table>
<%= will_paginate @top_ten_posts, :class => 'pagination ajax' %>
</p>
</div>
The controller's code is:
def index
@top_ten_posts = Post.paginate :page => params[:page], :per_page => 2 #get_top_ten.
respond_to do |format|
format.html
format.js {
render :update do |page|
page.replace_html 'top_ten_results', :partial => '/posts/top_ten'
end
}
end
end
I've also inserted the js code inside /public/javascripts/application.js file.
When I click on some page shown by will_paginate plugin it works fine. Now, when I look in the Console tab of the Firebug plugin for Firefox, I've noticed that many ajax calls are being executed just for that pagination click. Weird, ha?
Then I've noticed that I've got 14 posts to show, and there are 14 ajax calls...it looks like a coincidence, but I don't know why this is happening anyway.
Does anybody know what is happening?