Why Ajax renders 2 views in rails 3.1 app <p>When entering log in our rails 3.1 app, ajax is used to render the input screen below. Here is the link for log:</p> <pre><code>&lt;%= link_to 'Log', new_part_out_log_path(@part, :format =&gt; :js), :remote =&gt; true, :id =&gt; 'new_log_link' %&gt; </code></pre> <p>And the new.js.erb as this:</p> <pre><code>$("&lt;%= escape_javascript render(:file =&gt; 'out_logs/new.html.erb') %&gt;").insertAfter('#new_log_link'); $('#new_log_link').hide(); $('#close').hide(); </code></pre> <p>the problem is that after clicking 'Log', instead of one view, 2 identical views of out_logs/new.html.erb were rendered. What may be wrong with our code? thank so much. </p>