Link_to_remote show then hide


#1

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


#2

Kfir L. 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/Helpers/PrototypeHelper.html#M000420

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

Haven’t tested that though, but should work-ish.