Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well after stepping away from this problem for a while, I finally figured out the problems (there were multiple). Finally some closure!!</p> <ol> <li>I had errors in the jquery code that render the partial.</li> <li>I wasn't defining anything in my controller method.</li> </ol> <p>The greatest thing I learned from this is the power of the server logs. If anyone runs into a similar issue, check your server logs - especially when debugging jquery. What a useful tool! Depending on what you are doing (like rendering a partial), rails might not render your error message in your browser, but it may still appear in your server logs. For me, it was tossing up an error related to my partial. Hopefully down the road this saves at least one person a bit of time.</p> <p>Here's the final working code below. Please note that I changed some of the naming conventions and html structure too.</p> <p><strong>index.html.erb</strong></p> <pre><code>&lt;%= form_tag locations_path, :method =&gt; 'get', :id =&gt; "locations_search" do %&gt; &lt;p&gt; &lt;%= text_field_tag :search, params[:search] %&gt; &lt;%= submit_tag "Search", :name =&gt; nil %&gt; &lt;/p&gt; &lt;% end %&gt; &lt;div id="sidebar"&gt; &lt;div id="locations"&gt; &lt;%= render 'locations' %&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="content"&gt; &lt;div id="location-quickview"&gt; &lt;h2&gt;Select a Country...&lt;/h2&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>_locations.html.erb</strong></p> <pre><code>&lt;% @locations.each do |location| %&gt; &lt;div class="location"&gt; &lt;h4&gt;&lt;%= link_to location.name, quickview_location_path(:id =&gt; location.id), :remote =&gt; true %&gt;&lt;/h4&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre> <p><strong>_quickview.html.erb</strong></p> <pre><code>&lt;p&gt;&lt;%= location.name %&gt;&lt;/p&gt; </code></pre> <p><strong>routes.rb</strong></p> <pre><code>resources :locations do member do get 'quickview' end end </code></pre> <p><strong>locations_controller.html.erb</strong></p> <pre><code>def quickview @location = Location.find(params[:id]) respond_to do | format | format.js {render :layout =&gt; false} end end </code></pre> <p><strong>quickview.js.erb</strong></p> <pre><code>$("#quickview").html("&lt;%= escape_javascript(render(:partial =&gt; "quickview", :locals =&gt; {:location =&gt; @location})) %&gt;"); </code></pre>
    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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    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