Hi,
I’m trying some RJS to update a series of list boxes in which the user
selects a state, and the following list gets updated with a list of
counties, and the same for the next list of areas.
My code works perfectly (albeit a bit slow) on Firefox, but on Internet
Explorer it clears the list box (instead of filling it) and Netscape
shows all the counties cramped together on one instead of
multiple options.
This is the relevant code from the form:
Select a
state
Select a
county
<%= observe_field “county_state_id”, :url => {:action =>
‘update_counties_list’}, :with => ‘county_state_id’ %>
<%= observe_field “area_county_id”, :url => {:action =>
‘update_areas_list’}, :with => ‘area_county_id’ %>
And on the controller:
def update_counties_list
render :update do |page|
if params[‘county_state_id’].blank?
page.replace_html ‘address_area_id’, ‘Select a
county’
page.replace_html ‘colonia_municipio_id’, ‘Select a
state’
else
@state = State.find params[‘county_state_id’], :include
=> ‘counties’
page.replace_html ‘area_county_id’, ‘’
- options_from_collection_for_select(@state.counties, ‘id’, ‘name’)
end
end
end
Upon inspecting HTTP traffic it seems the JavaScript code is fine (it
works on Firefox after all), and neither IE nor Netscape show any error
whatsoever.
Weird thing is, on IE, if I open the RJS URL directly, sometimes it
works (showing the JS code), sometimes it doesn’t, showing an error
message saying it can’t download the url (the requested site is either
unavailable or cannot be found).
I’m on edge #4716 and I’ve tested on IE 6 & 7 beta 3.
I hope someone can help me
Kind regards,
Ivan V.