I have a sign-up (new user) process that is -- by convention -- split between a new and create action.
The problem is that the the new view has several hidden divs that are conditionally shown during the process of some Ajax callbacks. Here is an example. During the sign-up, the user has the choice of choosing an existing organization or entering new organization info. So the view contains:
<%= f.collection_select("organization", @orgs, :id, :org_name, {:include_blank => true }, { }) %> <%= observe_field "user_organization", :url => {:action => "org_selected"}, :with => "org_id" %>
If the user chooses an existing organization, my org_selected Ajax action looks like this:
org_id = params[:org_id] if org_id == "" ... elsif (org_id == "-1") ... else @org = Organization.find(params[:org_id]) render :update do |page| .... page.hide "new_org" page.show "existing_org" page["existing_org"].replace_html :partial => "existing_org_info" end end
This pattern repeats a few times (for employee position and location -- both of which are dependent on the company choice). During an Ajax callback, a hidden div is shown and a partial is rendered within it. The problem I have is that when a validation error occurs in create action after the user has filled in all these divs, I have to re- render the new view via render action :=> new, but the divs have lost their contents since they were partials rendered during Ajax callbacks.
Is there a recommended way to deal with this situation?
TIA