Note that there are some explanatory texts on larger screens.

plurals
  1. PORender a partial in rails using jquery
    primarykey
    data
    text
    <p>I am trying to setup a navigation bar on my home page that loads a partial into a div element when the user clicks on the links. I have followed the steps in this post and modified them as I thought I needed: <a href="https://stackoverflow.com/questions/4766383/rails-3-link-to-to-call-partial-using-jquery-ajax">Rails 3 - link_to to call partial using jquery ajax</a></p> <p>My code:</p> <p><strong>views/pages/home.html.erb:</strong></p> <pre><code>&lt;%= link_to "Files", :action =&gt; 'load_upload_partial', :remote =&gt; true %&gt; </code></pre> <p>. . .</p> <pre><code>&lt;div id="main_frame"&gt;&lt;/div&gt; </code></pre> <p><strong>pages_controller:</strong></p> <pre><code>def load_upload_partial respond_to do | format | format.js {render :layout =&gt; false} end end </code></pre> <p><strong>/views/uploads/load_upload_partial.js.erb:</strong></p> <pre><code>$("#main_frame").html( "&lt;%= escape_javascript( render( :partial =&gt; "/upload/upload_form" ) %&gt;" ); </code></pre> <p>The partial in this example is just a form. When I click on the link I get a blank page with this is the address bar: <a href="http://localhost:3000/load_upload_partial?remote=true" rel="nofollow noreferrer">http://localhost:3000/load_upload_partial?remote=true</a></p> <p>This makes me think that link is not triggering an ajax GET request (if that's the correct terminology). If that is the case is there anything I need to be adding to my application.js file? I followed the railscast #136 on rails and jquery but couldn't figure out which bits of the application.js code applied to my case. Any thoughts are much appreciated. Thanks. Tom</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload