Simple RJS question--toggling the text of a link_to_function link

Hey All,

I'm dabbling in a little DHTML to show/hide a fieldset on a page, w/
the following:

  <%=
    link_to_function("Show People", nil, :id => "more_link") do |page|
      page.visual_effect(:toggle_appear, "organization-people")
      page.replace_html("more_link", "Hide People")
    end
%>

This works very nicely, except for one thing--when the page loads, the
link attached to the resulting jscript function is "Show People". The
first time I click it changes to "Hide People" & the fieldset appears--
all very nice. My problem is that I don't know how to change the link
text back to "Show People" once the user clicks a second time. The
link always *does* what I want--showing or hiding as appropriate, but
it only *says* what I want for the first two clicks.

Is there a way to find out what the current link contains so I can
make that call to replace_html conditional?

Many thanks!

-Roy

Nobody has advice for me on this? :frowning:

Hi Roy,

You should post your javascript function if you want help with modifying
it. That's where the modification of the link text would 'normally'
happen.

Best regards,
Bill

Nobody has advice for me on this? :frowning:

you basically need to write some raw javascript for this ( if
('something'.innerHTML == ..)) and either mash that together with the
rjs stuff using << or just write the whole thing in javascript and
forget about the rjs bits

Fred

You mean I would have to sacrifice my carefully crafted complete
ignorance of javascript? Bummer. :wink:

Thanks guys. Perhaps today *is* a good day to start reading up on
javascript.

Thanks!

-Roy