Note that there are some explanatory texts on larger screens.

plurals
  1. PORe-rendering Reloading Partial in Rails
    primarykey
    data
    text
    <p>I have a list of links to posts on a page. When clicked, the link triggers a lightbox with a partial showing the post.</p> <p>My problem:</p> <p>1.) A user interacts with the lightbox and changes information about the post (favoriting, unfavoriting).</p> <p>2.) User then closes the lightbox</p> <p>3.) User reopens the lightbox by clicking on the link again. Lightbox information is NOT updated with the changes the user just made.</p> <p>4.) But if the user refreshes the whole page Ctrl+R and clicks on the lightbox, the lightbox will reflect the new changes.</p> <p>Lightbox I am using is FancyBox.</p> <p>Link to Lightbox</p> <pre><code> &lt;a class="fancyboxentry" rel="entries" href="#entryshow&lt;%= thispost.id%&gt;" onclick ="renderEntry&lt;%=thispost.id%&gt;()"&gt; &lt;%= image_tag(thispost.content_2)%&gt; &lt;/a&gt; </code></pre> <p>Dummy div to hold loaded partial.</p> <pre><code> &lt;div id="entryshow&lt;%= thispost.id %&gt;"&gt; &lt;/div&gt; </code></pre> <p>renderEntry function:</p> <pre><code> &lt;script&gt; function renderEntry&lt;%= thispost.id%&gt;() { $('#entryshow&lt;%= thispost.id%&gt;').html("&lt;%=escape_javascript(render(:partial =&gt; 'posts/show', :locals =&gt; {:id =&gt; thispost.id})).html_safe %&gt;");} &lt;/script&gt; </code></pre> <p>How can I get the partial to re-render, which means pulling new information from the database (checking whether it is favorited, new comments, etc) EVERY time the link is clicked? My current links seem to just cache old information until the page is refreshed.</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