Hi,
I''m developing a Rails app which uses dynamic forms. To implement
these, I''ve used AJAX and Rails''s built-in form observers.
Unfortunately, I''m having a problem.
This is how the form starts:
* Country select box [OBSERVED] (Republic of Ireland selected)
* County select box [OBSERVED] (none selected, list of Republic of
Irish counties in the drop down)
when a user selects a county, the browser requests the rest of the form:
* Country select box [OBSERVED] (Republic of Ireland selected)
* County select box [OBSERVED] (none selected, list of Republic of
Irish counties in the drop down)
* Town select box (none selected)
* Address line 1-3 (text inputs)
This works fine. The problem occurs when a different country is
selected. This reloads the rest of the form (including the observed
county select box if the country is Northern Ireland). When this
happens, the county select does not work. It does not trigger any AJAX
calls.
I believe this is caused by an event observer observing a replaced element.
What I''d like to be able to do is remove the form observer for the
county field when the country is changed, and put it back in when the
AJAX work is all done.
This would allow me to have a default country (kind-of handy as 99% of
addresses stored will be in the Republic of Ireland) and have the form
update accordingly.
Any ideas on how one would go around doing this? Documentation for
Prototype is sparse to say the least! :)
Dave
--
Site: http://antidis.com/