Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can I cache a partial retrieved through link_to_remote in rails?
    primarykey
    data
    text
    <p>I use link_to_remote to pull the dynamic contents of a partial onto the page. It's basically a long row from a database of "todo's" for the day.</p> <p>So as the person goes through and checks them off, I want to show the updated list with a line through those that are finished.</p> <p>Currently, I end up needing to click on the link_to_remote again after an item is ticked off, but would like it to redirect back to the "cached" page of to-do's but with the one item lined through.</p> <p>How do I do that?</p> <p>Here is the main view:</p> <pre><code>&lt;% @campaigns.each do |campaign| %&gt; &lt;!--link_to_remote(name, options = {}, html_options = nil)--&gt; &lt;tr&gt;&lt;td&gt; &lt;%= link_to_remote(campaign.name, :update =&gt; "campaign_todo", :url =&gt; {:action =&gt; "campaign_todo", :id =&gt; campaign.id } ) %&gt; &lt;/td&gt;&lt;/tr&gt; &lt;% end %&gt; &lt;/table&gt; &lt;div id="campaign_todo"&gt; &lt;/div&gt; </code></pre> <p>I'd like when the New/Create actions are done to go back to the page that redirected it there.</p> <p>When someone wants to "do" a task, it takes them to the new action. here is the controller:</p> <pre><code> def create @contact_call = ContactCall.new(params[:contact_call]) if @contact_call.save flash[:notice] = "Successfully created contact call." redirect_to contact_path(@contact_call.contact_id) else render :action =&gt; 'new' end end </code></pre> <p>I switched to redirect_to :back, which takes me back to the main view shown above...but WITHOUT the PARTIAL. It means I need to reload the partial all over again, which is a time-consuming database call.</p> <p><strong>1) Is it possible to go back to a view that has a partial called through AJAX and still have those results show up? 2) Can that result, however, be marked via CSS to indicate that it has been "checked off"?</strong></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.
    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