title: Rails 4 - Redirect to Next Page with Javascript using Kaminari
body: <p>I am currently using Kaminari for pagination, and I am aware of the <code>link_to_next_page</code> method.  However, I am currently looking to "link to the next page" within the pagination scope <em>after</em> a form has been processed and submitted.  </p>
  
  <p>In other words: </p>
  
  <ol>
  <li>The user clicks the "submit" button</li>
  <li>The form is submitted via <code>:remote =&gt; true</code></li>
  <li>Javascript programmatically directs the user to the next page.  </li>
  </ol>
  
  <p>Sort of like: 
      <strong>create.js.erb</strong></p>
  
  <pre><code>  &lt;% if @result %&gt;
      &lt;script type="text/javascript"&gt;
        window.location.href="&lt;%= @user.next_page %&gt;
      &lt;/script&gt;
    &lt;% end %&gt;
  </code></pre>
  
  <p>Is it possible for me to generate/determine what the next page is and then redirect the user via javascript?</p>
  
  <p>Thanks!</p>
  
  <p><strong>Final solution:</strong>
  Based on Kieran's help below, here's what I ended up doing:</p>
  
  <pre><code>&lt;% if @result %&gt;   
    &lt;% unless @users.last_page? %&gt;
    window.location.href="?page=&lt;%=@users.current_page+1 %&gt;"
    &lt;% else %&gt;
        window.location.href="completed"
  &lt;% end %&gt;
  </code></pre>
  
  <p>Which appears to work just fine for me.</p>