title: will_paginate + ajax deletion
body: <p>I've got a list of resources that I show on a paginated list using <a href="https://github.com/mislav/will_paginate" rel="nofollow">will_paginate</a>.</p>
  
  <p>I haven't customized anything, here's my view:</p>
  
  <pre><code>&lt;ul&gt;
  &lt;%= render :partial =&gt; "item_li", :collection =&gt; @items%&gt;
  &lt;/ul&gt;
  &lt;%= will_paginate @items %&gt;
  </code></pre>
  
  <p>Items is calculated like this on the controller:</p>
  
  <pre><code>@items = Item.find(:all)
  </code></pre>
  
  <p>The generated code is a simple html list with the pagination navigation links at the bottom:</p>
  
  <pre><code>&lt;ul&gt;
  &lt;li&gt;Item 1&lt;/li&gt;
  &lt;li&gt;Item 2&lt;/li&gt;
  ...
  &lt;li&gt;Item 10&lt;/li&gt;
  &lt;/ul&gt;
  &lt;div class="pagination"&gt;
    &lt;span class="disabled prev_page"&gt;Previous&lt;/span&gt;
    &lt;span class="current"&gt;1&lt;/span&gt;
    ...
  &lt;/div&gt;
  </code></pre>
  
  <p>I have included a "delete" button on my items. When that link is pressed, there's an ajax call to the server and the item disappears from the list (the <code>&lt;li&gt;</code> will is replaced by <code>""</code>)</p>
  
  <p>My problem comes with the navigation links.</p>
  
  <ul>
  <li>Say that I had items 1 to 10 on the first page, items 11 to 20 on the second, etc.</li>
  <li>Say that I delete items 1, 2 and 3 on the first page.</li>
  <li>And then I press "next".</li>
  </ul>
  
  <p>The server will "recalculate" the list of items; since I removed 3 of the previous list, it will return items 13 to 22. In other words, items 10, 11 and 12 don't appear on the first page nor the second.</p>
  
  <p>How can I solve this in a simple, elegant way?</p>
  
  <p>So far the only solution I could find was reloading the whole page after each deletion, but then using ajax becomes pointless.</p>
  
  <p>Thanks a lot.</p>