How do I code this anchor tag as a link_to in Rails?

I'm trying to code this anchor tag in Rails. It's just a link to use scriptaculous to "blind" open a div that I've got hidden by default.

<a href="#" onClick="Effect.toggle('add_comment','blind'); return false">Add comment</a>

Also, how would Rails degrade this link if javascript was disabled? In other words, how do I get it to display by default if javascript was disabled? Or would I be responsible for that, not Rails?

Thanks for any help.

I'm trying to code this anchor tag in Rails. It's just a link to use scriptaculous to "blind" open a div that I've got hidden by default.

<a href="#" onClick="Effect.toggle('add_comment','blind'); return false">Add comment</a>

link_to_function 'Add Comment', 'your javascript here'

Also, how would Rails degrade this link if javascript was disabled? In other words, how do I get it to display by default if javascript was disabled? Or would I be responsible for that, not Rails?

You would have to do that.

Fred

Thanks Fred. That worked great.

But as far as me allowing non-javascript users to see the form by default, I was thinking I could just use javascript to set the "display: none" styling. I tried that by doing this:

<%= javascript_tag "window.document.getElementById(add_comment).style.display=none;", :defer => 'defer' -%>

but I get a javascript error "add_comment is not defined". I know it's defined but am I implementing the javascript incorrectly? What's the "rails way" to do this? Put my javascript somewhere else, instead of at the bottom of this particular view I'm in?

Thanks again.

And btw, here's the html for "add_comment":

<div id="add_comment"><div>   <h3>Add Comment</h3>   <%= render :partial => @comment = Comment.new, :locals => { :button_name => 'Add comment' } -%> </div></div>

Thanks Fred. That worked great.

But as far as me allowing non-javascript users to see the form by default, I was thinking I could just use javascript to set the
"display: none" styling. I tried that by doing this:

<%= javascript_tag "window.document.getElementById(add_comment).style.display=none;", :defer => 'defer' -%>

You needed to quote it (getElementById('add_comment')). You can write
this more concisely if you're using prototype: $('add_comment').hide()

Fred

Thanks again Fred...you're the man. Prototype really cleaned that up.

And I guess I didn't need to use the "defer" option...seems to work without it?