Clearing out submitted form

I’m trying to put together a basic blog application for fun, and I’m
using an RJS template to insert a new comment into existing comments.
The comment data is inserted, but the comment form at the bottom of the
page still contains the comment. I tried to clear out the text from the
form this way:

page.insert_html :top, ‘comments’, :partial => ‘show_comment’
page.replace_html ‘blog_entry_comment_body’, ‘’
page.replace_html ‘blog_entry_comment_subject’, ‘’

But this doesn’t work either. Any thoughts on how to clear out the form
contents after the comment is added? The form looks like this:

<% form_remote_tag(:url => {:action => ‘ajax_add_comment’, :controller
=> ‘Comment’, :id => }) do %>

<%= render :partial=>"comment/form" %>
<%= submit_tag 'Add Comment' %>

<% end %>

Firefox may also be putting the data in the form, as part of it’s
auto-completion functionality, I suppose. Same behavior is present in

Thanks in advance,

page.replace_html ‘blog_entry_comment_body’, ‘’
page.replace_html ‘blog_entry_comment_subject’, ‘’

this isn’t doing what you think it is doing. it replaces the contents
of tags, not the values. (actually, replace_html will work on a
textarea, but will not on type=“text” input)

you want to do something like:

blog_entry_comment_body => textarea

page << “$(‘blog_entry_comment_body’).value = ‘’”

also works

#page.replace_html(‘blog_entry_comment_body’, ‘’)

blog_entry_comment_subject => input type=“text”

page << “$(‘blog_entry_comment_subject’).value = ‘’”

you are submitting the form via ajax, so therefore the page is not
being ‘reloaded’ and thus firefox or IE is not auto-filing the forms
for you at this point because you never left the page.

You can also use Collection Proxies in RJS like so :‘div textarea’).each do |element|

This takes all of the text areas in a div and replaces the value. You
could also use the div name like so :’#id_of_textarea_here’).each do |element|

So if I had a <textarea id=“id_of_textarea_here” …

That should replace the value.