I've got a Rails form that has an observe_field which performs an ajax request when a drop down list is changed. The ajax causes the form to be re-rendered (the form is in a partial) with an extra param that causes some text on the page to change. All that works fine, but when I refresh the page (I'm running firefox), the text is reset and the drop down list does not change its value. Thus, I end up with a select value that does not correspond to the dynamic text.
I have tried setting a default selected value of the drop down, but for some reason firefox won't change the value with a page refresh.
This is the code for the drop down in the view:
<%= select_tag :category, options_from_collection_for_select(@categories, :letter, :name, @letter) %>
@letter is set dynamically and controls the dynamic text on the page.
This is the action that is rendered on a page refresh:
def new
@part = Part.new
@letter = params[:letter] || "A"
@part.cpn = Part.find_next_cpn(@letter)
@categories = PartCategory.find(:all)
respond_to do |format|
format.js
format.html
end
end
I need a way to either retain the dynamic text information or reset the drop down menu.