Setup:
A form which initially has only one field: a 2x group of radio_buttons.
As the user selects options, additinal fields are added or removed.
I started with observe_field. I was getting some very peculiar behavior
from observe_field and finally figured out why =>
Observe field only works for the first click. So it’s not suitable for
a form that reacts to user input since a user may select/unselect an
option multiple times.
Next, I decided to use observe_form. At first, it seemed to overcome
the problems of observe_field and reacted to every click of the
radio_button. But then I discovered that it doesn’t observe changes in
fields that are not in the original source (the fields added by the
user). So I’m back to ground zero.
I suppose I could build all the DOM objects from scratch and roll my
own functions for adding/removing and call them via onclick(), but I
was hoping to get away from some of the:
var myDiv = document.createElement(‘div’);
var link = document.createElement(‘a’);
link.setAttribute(‘href’, ‘somepage.php’);
var text = document.createCreateTextNode(‘Link Name’);
link.appendChild(text);
myDiv.appendChild(link);
in lieu of rjs goodness like:
myElement = “
page.replace_html :elementId, myElement
Any help appreciated