Note that there are some explanatory texts on larger screens.

plurals
  1. PORefresh HTML Content Provided by Embedded Ruby Without Reloading the Page
    primarykey
    data
    text
    <p>I have had some trouble finding a solution to this. Basically, I have an embedded ruby each loop whose body is a partial being rendered for a certain sub group of a model. For instance:</p> <pre><code>&lt;li id="thing"&gt; &lt;% items.each do |i| %&gt; &lt;%= render :partial =&gt; 'item', :locals =&gt; {:i =&gt; i} %&gt; &lt;% end %&gt; &lt;/li&gt; </code></pre> <p>I was wondering if there was a way with jQuery, AJAX, or even just rails (I'm sure that each one has a implementable solution for me, and I'm interested in all of them) to refresh that list of items. The reason I would want to be able to do this is, currently, I have implemented the functionality to allow a now 'item' to be created or an existing 'item' be updated, again, without having to reload the page (the form comes up in a certain container on a button click in both cases), and I would like upon submission for the list to automatically be updated with the new information or new 'item.' Would it be a better approach to try and refresh the entire list? Or is there a way to append the newly created/updated object to the list of partials (as a partial) clientside?</p> <p>I tried the following statement, but I can't seem to avoid getting the "undefined method" error on render.</p> <p><code>$("#activeTab").append("&lt;%= escape_javascript(render :partial =&gt; 'item', :locals =&gt; {:i =&gt; Item.order(:created_at).last}) %&gt;");</code></p> <p>I figured this would be a good solution because once the page was navigated away and came back to, the list would be loaded again. This is just to append to the static list while you are still on the page.</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.
    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