Forum: Ruby on Rails Hide & Show div (Element.toggle)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ead43bcb0202410540a6a7cee5955d46?d=identicon&s=25 Fresh Mix (giga)
on 2008-12-26 18:14
I have 2 divs:

<div id="div1">  <%= link_to_function("Show div2",
"Element.toggle('div2')") %> </div>
<div id="div2">  <%= link_to_function("Show div1",
"Element.toggle('div1')") %> </div>

I want, when I click link: "Show div2" it hide div1 and show div2,
when i click "Show div1" it hide div2 and show div1

How can i do it?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-12-26 18:35
(Received via mailing list)
On Dec 26, 5:14 pm, Gi Ga <rails-mailing-l...@andreas-s.net> wrote:
> How can i do it?
just make your call to link_to function toggle both divs - you aren't
limited to a single javascript statement.

Fred
Ead43bcb0202410540a6a7cee5955d46?d=identicon&s=25 Fresh Mix (giga)
on 2008-12-26 20:32
Frederick Cheung wrote:
> On Dec 26, 5:14�pm, Gi Ga <rails-mailing-l...@andreas-s.net> wrote:
>> How can i do it?
> just make your call to link_to function toggle both divs - you aren't
> limited to a single javascript statement.
>
> Fred


I can't make it work :(

By default div2 is hidden:

<div id="div1">
  <%= link_to_function("Show div2", "Element.toggle('div1', 'div2)") %>
</div>
<div id="div2" style="display:none;">
  <%= link_to_function("Show div1", "Element.toggle('div1', 'div2')") %>
</div>
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-12-26 20:48
(Received via mailing list)
On 26 Dec 2008, at 19:32, Gi Ga wrote:

> I can't make it work :(
Just make two calls to Element.toggle

Fred
Ead43bcb0202410540a6a7cee5955d46?d=identicon&s=25 Fresh Mix (giga)
on 2008-12-27 08:59
Sample?
2a31ce1f0273b12896b4049bf3eb4ce8?d=identicon&s=25 Shiv N Gautam (Guest)
on 2008-12-27 09:28
(Received via mailing list)
Sample:

Element.toggle('div1'); Element.toggle('div2');

--
Shiv

On Sat, Dec 27, 2008 at 1:29 PM, Gi Ga
<rails-mailing-list@andreas-s.net>wrote:

>
> Sample?
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>


--

Henny Youngman  - "If at first you don't succeed... so much for
skydiving."
This topic is locked and can not be replied to.