Forum: Ruby on Rails AJAX: do render but show element in same click?

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.
602f73f02a8b8abcf01ca093e1762006?d=identicon&s=25 Micah Bly (yak)
on 2006-02-28 21:15
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
70375a32ad79987b9bc00cb20f7d1c95?d=identicon&s=25 Dean (Guest)
on 2006-03-01 01:25
(Received via mailing list)
Micah Bly wrote:
> 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 --
602f73f02a8b8abcf01ca093e1762006?d=identicon&s=25 Micah Bly (yak)
on 2006-03-01 19:17
Dean wrote:
>
> <%= 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,

Thanks for the help.  You know, I *do* spend time with the API, it's
just there's a lot to learn... I read that section twice, didn't pick up
on the fact I could be launching other JS actions... <sigh>

This does work for me btw, but only once.  It shows the div, but once I
do element.hide(), this won't ever show the div again. I ended up using
element.update('mydiv','') as the "hide" action. It works *almost* as
well.

Thanks again,

Micah
This topic is locked and can not be replied to.