# Updating several divs within a controller

**URL:** <https://www.ruby-forum.com/t/updating-several-divs-within-a-controller/105312>\
**Category:** Rails\
**Created:** [May 28, 2007, 7:00pm UTC](https://www.ruby-forum.com/t/updating-several-divs-within-a-controller/105312 "2007-05-28T19:00:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jochen\_kaechelin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/48db29/32.png) [@jochen\_kaechelin](https://www.ruby-forum.com/u/jochen_kaechelin)\
**Post date:** [May 28, 2007, 7:00pm UTC](https://www.ruby-forum.com/t/updating-several-divs-within-a-controller/105312/1 "2007-05-28T19:00:49Z")

</div>

I would know if it’s possible to do the following:

I have a head-DIV, main-Div and a navigation-DIV and a  
global application Layout.

* * *

- 

```
 head -

```

- link1 link2 link3 -

* * *

* * *

* * *

- nav - main -

* * *

* * *

* * *

* * *

When I click a link in the head-DIV (link\_to) I load  
the according rhtml-File within the controller -\> the main-DIV  
is updated showing the requested content.

How can I update the nav-DIV to present a submenu to the user?  
Must I call a render calling a rjs file with replace\_html or is  
there a more recommended way to do this?

Thanx

---

<div class="post-metadata">

**Author:** ![jochen\_kaechelin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/48db29/32.png) [@jochen\_kaechelin](https://www.ruby-forum.com/u/jochen_kaechelin)\
**Post date:** [May 28, 2007, 8:10pm UTC](https://www.ruby-forum.com/t/updating-several-divs-within-a-controller/105312/2 "2007-05-28T20:10:00Z")

</div>

On 5/28/07, jochen kaechelin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> * * *
> 
> is updated showing the requested content.
> 
> How can I update the nav-DIV to present a submenu to the user?  
> Must I call a render calling a rjs file with replace\_html or is  
> there a more recommended way to do this?

That would be the best idea IMO. I had to do the same you need and i  
tried some solutions, the best one to keep clean code and performance  
is the rjs with the replace\_html.

---

<div class="post-metadata">

**Author:** ![jochen\_kaechelin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/48db29/32.png) [@jochen\_kaechelin](https://www.ruby-forum.com/u/jochen_kaechelin)\
**Post date:** [May 28, 2007, 8:20pm UTC](https://www.ruby-forum.com/t/updating-several-divs-within-a-controller/105312/3 "2007-05-28T20:20:00Z")

</div>

Emilio T. schrieb:

> > * * *
> > 
> > is updated showing the requested content.
> > 
> > How can I update the nav-DIV to present a submenu to the user?  
> > Must I call a render calling a rjs file with replace\_html or is  
> > there a more recommended way to do this?
> 
> That would be the best idea IMO. I had to do the same you need and i  
> tried some solutions, the best one to keep clean code and performance  
> is the rjs with the replace\_html.

Could you give me a code-example please?

controller:

def index  
end

template:  
index.rhtml (rendered in the main-DIV)

Where must I put the rjs code that the navigation gets updated when  
the index.rhtml is rendered?

Thanx
