# Strategies for updating multiple parts of the page with AJAX

**URL:** <https://www.ruby-forum.com/t/strategies-for-updating-multiple-parts-of-the-page-with-ajax/65066>\
**Category:** Rails\
**Created:** [February 9, 2006, 5:07pm UTC](https://www.ruby-forum.com/t/strategies-for-updating-multiple-parts-of-the-page-with-ajax/65066 "2006-02-09T17:07:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tlianza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ce7236/32.png) [@tlianza](https://www.ruby-forum.com/u/tlianza)\
**Post date:** [February 9, 2006, 5:07pm UTC](https://www.ruby-forum.com/t/strategies-for-updating-multiple-parts-of-the-page-with-ajax/65066/1 "2006-02-09T17:07:17Z")

</div>

Hi all,

I have a layout that’s evolving, but it looks like there will be several  
divs. I’m trying to keep everything AJAX-y and avoid full page reloads.  
My  
problem is, if I have the login box in a div, I’m going to want two  
other  
divs to effectively “refresh” themselves to get data from the server now  
that there is a user logged in.

I’m trying to figure out how to accomplish this. I know I can’t do this  
with my current layout, because each of these divs I want to refresh is  
currently just a partial page template included on a page - nothing  
AJAXy  
about them. If I want to have the ability to call on parts of the page  
to  
update themselves, any ideas how I can do that? I’m not sure if there  
are  
rails helpers I can use, or if I should start looking into hand-coding  
Javascript with the prototype library to come up with a way.

Also, if my mental model of how to do page updates is wrong, please  
correct  
me.

Thanks!  
Tom

---

<div class="post-metadata">

**Author:** ![tlianza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ce7236/32.png) [@tlianza](https://www.ruby-forum.com/u/tlianza)\
**Post date:** [February 9, 2006, 5:34pm UTC](https://www.ruby-forum.com/t/strategies-for-updating-multiple-parts-of-the-page-with-ajax/65066/2 "2006-02-09T17:34:03Z")

</div>

Tom L. wrote:

> Hi all,
> 
> I have a layout that’s evolving, but it looks like there will be several  
> divs. I’m trying to keep everything AJAX-y and avoid full page reloads.  
> My  
> problem is, if I have the login box in a div, I’m going to want two  
> other  
> divs to effectively “refresh” themselves to get data from the server now  
> that there is a user logged in.

Sounds like you might like RJS templates. They are in edge rails but I  
think there is a plugin for rails 1.0.

Alternatively, you could add some javascript to the :complete callback  
in link\_to\_remote that will fire off another request.

link\_to\_remote ‘link’, :update=\>‘testdiv’, :url=\>{:action=\>‘action’},  
:complete=\> remote\_function(:update=\>‘testdiv2’,  
:url=\>{:action=\>‘action2’})

should do the trick.

\_Kevin

---

<div class="post-metadata">

**Author:** ![tlianza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ce7236/32.png) [@tlianza](https://www.ruby-forum.com/u/tlianza)\
**Post date:** [February 9, 2006, 5:38pm UTC](https://www.ruby-forum.com/t/strategies-for-updating-multiple-parts-of-the-page-with-ajax/65066/3 "2006-02-09T17:38:49Z")

</div>

just take a look at RJS (at rails edge), this is the easiest way for  
multiple partial AJAX page reloads without handcoded javascript
