title: Ruby on Rails3: execute rails code into js.erb view, does not work
body: <p>I want to do kaminari paginator dynamically</p>
  
  <p>This code, handle click event to Kaminari links</p>
  
  <p>Kaminari.js</p>
  
  <pre><code>$(document).ready(function() {
    $(".paginator a").on("click", function() {
      $.getScript(this.href);
      return false;
    });
  });
  </code></pre>
  
  <p>users_controller:</p>
  
  <pre><code>def index
    @users = User.all(:order =&gt; "name")
    @users = Kaminari.paginate_array(@users).page(params[:page]).per(10)
  end
  </code></pre>
  
  <p>index.html.erb</p>
  
  <pre><code>&lt;h1&gt;Users&lt;/h1&gt;
  &lt;div id="users-page"&gt;
    &lt;%= render 'users'  %&gt;
  &lt;/div&gt;
  
  &lt;%= paginate @users %&gt;
  </code></pre>
  
  <p>Then I wrote a js.erb view for users dynamically pagination:</p>
  
  <p>app/views/users/index.js.erb</p>
  
  <p>If I only put javascript code like</p>
  
  <pre><code>alert("paging");
  </code></pre>
  
  <p>when I click on paginations links, alert message perfectly.</p>
  
  <p>But if I put &lt;%= ... %> code inside, this javascript response does not execute.</p>
  
  <pre><code>alert("paging");
  $("#users-page").html(&lt;%= render 'users' %&gt;)
  </code></pre>
  
  <p>either the message is displayed.</p>
  
  <p>which may be the problem?</p>