I got this unusual problem in my rails app. I have a view where i'm using RESTful routes.
In my view do i have an index and a show action. In my index do i use will\_paginate for some rows i'm printing from a table. When i press next on the pagination it makes a ajax request and render the next 5 rows. Everything works fine first time i load the site and when i click next it is processed to the controller by JS. But when i click show on one of the posts i print from my table and is directed to the show.html.erb and press on a button to come back to the index i get the unusual problem with the ajax call on my pagination. If i click next for example it is processed by HTML. If i update the index again, the ajax call work again.

index.html.erb

```
<% @posts.each do |post| %>
<%= post.name %>
<%= link_to 'show', post_path(post) %>
<% end %>
<div class="show_pagination"><%= render 'posts/pagination' %></div>

```

\_pagination.html.erb

```
<div class="pagination">
<%= will_paginate @posts, :page_links => false %>
</div>

```

index.js.html

```
$('.show_pagination').html('<%= escape_javascript(render("posts/pagination")) %>');

```

show.html.erb

```
<%= @posts.name %>
<%= link_to 'All posts', posts_path %>

```

posts\_controller.rb

```
def index
@posts = Post.paginate(page: params[:page],:per_page => 5).all.order('created_at DESC')
end

def show
@posts = Post.find(params[:id])
end

```

application.js

```
$(document).ready(function () {
    $("body").on("click", '.show_pagination .pagination a', function(e){
        e.preventDefault();
        $.getScript(this.href);
        return false;
    });
});

```

I do not get any errors in my javascript console, or in the rails console.
I'm using ROR 4, and is using the Jquery and Jquery ui gem.

Thanks in advance.