title: RAILS Auto refresh partial
body: <p>I have a controller events with action show :</p>
  
  <pre><code>  def show
      @event = Event.get(params[:id])
  
      if !connected? || !@event 
        return redirect_to request.referrer || root_path
      end
  
      @requests = @event.get_requests
    end
  </code></pre>
  
  <p>In view <strong>show.html.erb</strong> i have </p>
  
  <pre><code>&lt;script&gt;
    $(document).ready(
       function() {
        setInterval(function() {
          $('#requests').load('/events/reload_requests');
      }, 2000);
    });
  &lt;/script&gt;
  ...
  &lt;div class="party-block" id="requests"&gt;
      &lt;%= render partial: 'requests' %&gt;
  &lt;/div&gt;
  ...
  </code></pre>
  
  <p>The javascript function call controller method <strong>events/reload_requests</strong> :</p>
  
  <pre><code>def reload_requests
    @requests = @event.get_requests
    render partial: 'events/requests'
  end
  </code></pre>
  
  <p>And content of partial <strong>_requests.html.erb</strong> :</p>
  
  <pre><code>&lt;%= Time.now %&gt;
  &lt;h4&gt;&lt;%= t '.requests' %&gt;&lt;/h4&gt;
  &lt;% @requests.each do |r| %&gt;
   &lt;span class="request"&gt;
   ...
  &lt;% end %&gt;
  </code></pre>
  
  <p>Problem : The javascript function load all the content of my <strong>show.html.erb</strong> page in div <strong>#requests</strong>, but in the copy of <strong>show.html.erb</strong> in the div, it refresh div #request correctly :
  <a href="http://i.stack.imgur.com/eEBZi.jpg" rel="nofollow">enter image description here</a>
  You can see, in show#requests i have the content of show.
  Than you</p>