AJAX: do render but show element in same click?

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

Micah B. 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 –

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…

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