Trying to understand periodically_call_remote() javascript prototype helper

I have the following code snippet on the documents#index view page of
my rails app.

<%= periodically_call_remote(
:url => {:controller => ‘documents’, :action => ‘index’},
:update => ‘documents’,
:method => ‘get’ )
%>

The page shows a table of document records. Since these records can
be updated asynchronously by a message broker feed, I want the above
code to activate every 10 seconds (the default) and refresh the page.

Now, the page has a sidebar and when the time ticks the first time, I
get a complete copy of the entire page, including the sidebar,
inserted into the main table section of the page. I think the problem
is in specifying the :update => ‘documents’ div, but I just don’t get
how to scope the region to be updated.

I can supply more info, such as the layout page and so forth, just ask.

explainer wrote:

I have the following code snippet on the documents#index view page of
my rails app.

<%= periodically_call_remote(
:url => {:controller => ‘documents’, :action => ‘index’},
:update => ‘documents’,
:method => ‘get’ )
%>

The page shows a table of document records. Since these records can
be updated asynchronously by a message broker feed, I want the above
code to activate every 10 seconds (the default) and refresh the page.

Now, the page has a sidebar and when the time ticks the first time, I
get a complete copy of the entire page, including the sidebar,
inserted into the main table section of the page.

Please ask Rails questions on the Rails mailing list in future. This
mailing list is for Ruby (the programming language) not Rails (the web
framework).

But for a quick answer, I suspect that you need to check in your
controller for an AJAX request and return only the part of the page you
want inserted, not the whole page.

e.g.

if request.xhr?
render :partial=>“something”, :object=>something
else
… do normal HTML rendering
end