How to toggle several divs at the click?

Hey all,
I have several divs like this:

blabal
blabal
blabal

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 A. wrote:

Hey all,
I have several divs like this:

blabal
blabal
blabal

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

Use RJS.

myaction.rjs

page.select(‘div.collapseme’).each { |item| item.hide }

A.

Patrick A. napisał(a):

Hey all,
I have several divs like this:

blabal
blabal
blabal

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.


RaW

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’);}