Forum: Ruby on Rails link_to_remote show then hide

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.
E6b040ecc51de500ee5a6f83aa3adc68?d=identicon&s=25 Kfir Lavi (Guest)
on 2006-06-01 16:21
(Received via mailing list)
Hi,
I have a link_to_remote and it update a div.
After the first click the div is opened with the information.
Now I want to be able to close hide the div .
How should I do it.
Someone at the IRC told me to use toggle.
But what I want is a bit odd. I want that it will not do again
link_to_remote but toggle.

Tnx
Kfir
2da252cc1d2fb3701126171831b50a65?d=identicon&s=25 Dave Coleman (pezdude)
on 2006-06-01 17:26
Kfir Lavi wrote:
> But what I want is a bit odd. I want that it will not do again
> link_to_remote but toggle.

Instead of link_to_remote you could use remote_function
http://api.rubyonrails.org/classes/ActionView/Help...

then put a condition around that:

<a href="#" onclick="if ($('thing').style.display == 'none') {
                     <%= remote_function(:update => "thing",
                     :url => { :action => :update_options },
                     :complete => "new Effect.BlindDown('thing');") %>
                     }
                     else { new Effect.BlindUp('thing'); } return
false;">weeee</a>

<div id="thing" style="display:none;"></div>

Haven't tested that though, but should work-ish.
This topic is locked and can not be replied to.