my view:
<td> <div id="event_category_select"> <%= render :partial => "event_category_select" %> </div> <br/> <div id="event_category_text_field"> <%= render :partial => "event_category_text_field" %> </div> </td> <td> <div id="event_description_select"> <%= render :partial => "event_description_select" %> </div> <br/> <div id="event_description_text_field"> <%= render :partial => "event_description_text_field" %> </div> </td>
_event_category_select.html.erb: <%= select_tag :select_category, options_for_select(@categories, selected = @selected_category), {:onchange => remote_function(:url => {:action => :select_category}, :with => "select_category")} %>
_event_category_text_field.html.erb: <%= text_field_tag :category, @selected_category, :size => 30 %>
_event_description_select.html.erb: <%= select_tag :select_description, options_for_select(@descriptions, selected = @selected_description), {:onchange => remote_function(:url => {:action => :select_description}, :with => "select_description")} %>
_event_description_text_field.html.erb: <%= text_field_tag :description, @selected_description, :size => 60 %>
controller:
def select_category @selected_category = params[:value] search_hash = {:select => "DISTINCT description"} search_hash[:conditions] = ["category = ?", @selected_category] if @selected_category != "" @descriptions = ["", *Event.find(:all, search_hash).map(&:description)] @selected_description = "" render :update do |page| page.replace_html "event_category_text_field", :partial => "event_category_text_field" page.replace_html "event_description_select", :partial => "event_description_select" end end
def select_description @selected_description = params[:value] @categories = ["", *Event.find(:all, :select => "DISTINCT category").map(&:category)] if @selected_description != "" selected_event = Event.find(:first, :conditions => ["description = ?", @selected_description]) @selected_category = selected_event.category if selected_event else @selected_category = "" end render :update do |page| page.replace_html "event_category_select", :partial => "event_category_select" page.replace_html "event_description_text_field", :partial => "event_description_text_field" end end
With ie 7.0 everything's fine, but with firefox 3.0:
When I select a category, the two ids are replaced. After that, I want to select a description, but it doesn't send a request. However, selecting another category does. The same the other way round, i.e. when I begin with selecting a description.
The source code is of no avail, because with both browsers it never changes whatever I select.
Any idea?
Thanks Luma