[Rails] AJAX: do render but show element in same click?

Dean dean at deanandadie.net
Wed Mar 1 00:25:27 GMT 2006


Micah Bly wrote:
> I'm a rails newbie.
> 
> I've got a link_to_remote that puts a partial render into a div
> ("note1", "note2", etc.).  As part of the display that comes up, I put
> in a hide note link (element.toggle).  Click that, the div goes away,
> everything's great... except now I can't get it back.
> 
> How can I call the remote AND make the div show at the same time? I see
> element.show, but I don't know how to execute that without having the
> user click on it. I looked at the API for update_element_function, but
> that looks like I can change the content of the div, or it's position,
> but not hide/show it.
> 
> Micah

<%= link_to_remote "Do AJAX!", :update => "note1", :loaded => 
"element.show('note1') %>

Find more cool things to do with link_to_remote at http://api.rubyonrails.org/

--Dean
--
Take your time, take your chances
[3278.7 km, 273.4] Apparent Rennerian
--------------------------------------------------------------------------------
It matters not how strait the gate, / How charged with punishments the scroll,
I am the master of my fate: / I am the captain of my soul.        -- Invictus --
                                                           -- William E Henley --


More information about the Rails mailing list