I have a method in my controller like the following (the syntax may not
be correct, I’m doing this from memory - you should be able to get the
idea though) My rhtml page has a DIV with id=“country_areas”, which
contains a partial that only makes a drop down of country areas for a
specific country. When changing the country in the country drop down, it
uses the :observe_field to call the below method and refresh the
country_areas partial.
def find_country_areas
@country_areas = Country.find(:all, :condition => (“country_id =?”,
params[:country_id]) )
render :partial => “country_areas”, :object => @country_areas
end
The country areas drop down is getting changed to reflect those country
areas that are for a specific country, so all is well.
Now if I change the above method to:
def find_country_areas
@country_areas = Country.find(:all, :condition => (“country_id =?”,
params[:country_id]) )
end
and use a find_country_areas.rjs:
page.relace ‘country_areas’, :partial => ‘country_areas’, :object =>
‘@country_areas’
it works correctly the first time I change a country. But any subsequent
changes to the country drop down do not re-render the partial at all (ie
the same areas are populated as the first country I selected). My method
is getting called, but no refresh of the partial.
Why do these behave differently? I want to use rjs because ultimately I
have two partials that I want to refresh.
Thanks
Brian