how to toggle several divs at the click?

Hey all,
I have several divs like this:
<div class="collapseme" style="display:none" >blabal</div>
<div class="collapseme" style="display:none">blabal</div>

I would like to do a link_to_function or link_to_remote to make them
visible all by one click.

Any idea how to do that?

thanx in advance

Pat

Patrick Aljord napisaƂ(a):

Hey all,
I have several divs like this:
<div class="collapseme" style="display:none" >blabal</div>
<div class="collapseme" style="display:none">blabal</div>

I would like to do a link_to_function or link_to_remote to make them
visible all by one click.

Any idea how to do that?

You can do this with 'link_to_remote' with the request to e.g. 'change' action.
But instead of 'change.rhtml' use 'change.rjs' template.
Inside this template you can use e.g. 'page.show' for as many divs as you wish. You should give your divs 'id' parameter to reference them in 'page.show' methods.

RJS Is not a must, you can use a JS onclick event.

link_to 'Open Divs', "#", {:onclick => 'Element.toggle('div1_id');
Element.toggle('div2_id');}