I’m trying to clear the input fields on an Ajax form. Unfortunately,
I’ve tried this just about every way I can
think of and instead of clearing the fields, it’s clearing pretty much
the whole page. I would really appreciate some help!
The page has a form that allows the entry of two fields. The form
exists inside a
new line is added to the page inside a
The user can add as many lines as they want. I want to clear the fields
each time they click the button. What’s happening instead is that the
entry
The code is below. Any ideas?
Thanks in advance,
Bill
— Here’s _entry_form.rhtml —
<%= form_remote_tag(:update => ‘ingredient_list’,
:url => {:action => :add_ingredient},
:position => ‘bottom’,
:after => {:action => :clear_entry}) %>
Name:
<%= text_field_tag :name %>
Amount:
<%= text_field_tag :qty %>
<%= submit_tag ‘Add Ingredient’ %>
<%= end_form_tag %>
— and here’s the clear_entry action in the controller ----
def clear_entry
render :update do |page|
page.entry.name.value = ‘’
page.entry.qty.value = ‘’
end
end