Multiple observer

Hi

I have three drop downs (State, City, Locality) and would like to
populate
City based on State selection and Locality based on City selection.

I have observers on two fields (State, and City). The observer_field on
state
works fine and it populates city based on state selection. But the
observer
on city doesn’t populate Locality. Now sure whats wrong with my code.

here is the code snippet

RHTML Code:

<% @states.each do |state| %> <%= state.state_name %> <% end %>
Select City
<%= observe_field("state[id]", :update => "city_container", :url => { :action => :select_city }, :with => "'id='+value", :on => "changed") %>
Select Locality
<%= observe_field("city_id", :update => "locality_container", :url => { :action => :select_locality } :with => "'id='+value", :on => "changed") %>

Controller Code

def select_city
@cities = City.find_all_by_state_id(@params[“id”])
@html = “”
@html += “Select City”
@cities.each do |@city|
@html += “#{@city.city_name}”
end
@html += “”
render_text @html
end

def select_locality
@localities = Locality.find_all_by_city_id(@params[“id”])
@html = “”
@html += “Select Locality”
@localities.each do |@locality|
@html += “#
{@locality.locality_name}”
end
@html += “”

render_text “test”

   render_text @html

end

I tried with render_text “test” just to make sure that i get the text
“test”
back on selecting City. But that also doesn’t work. Is there a work
around?

Thx for your help,
Ramanan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs