Hello,
I have select field which after a choice happened, feeds another select
field.
Using the gem Cocoon to duplicate this set of select fields.
My problem now is to find a solution that the coffee script supplies
values
for each select field-set separately.
One thing to remember, conceptually, is that you cannot replace the “innards” of
a select as if they were HTML without destroying its ability to react correctly to
scripting or user input. The only “bulletproof” way to update the contents of a
select is to set its options collection length to 0, then iterate over your
collection of data, using the new Option(text,value) constructor to build each
option. Doing it any other way will end in tears. This has nothing to do with
CoffeeScript or JavaScript and everything to do with browsers and the DOM.
Walter
Thanks Walter…
may be you have some code to demonstrate…so I get the idea ?
I think I need some reference to supply to the script but don’t know how.
Any help would be great. Thanks
One thing to remember, conceptually, is that you cannot replace the
“innards” of a select as if they were HTML without destroying its
ability to react correctly to scripting or user input. The only
“bulletproof” way to update the contents of a select is to set its
options collection length to 0, then iterate over your collection of
data, using the new Option(text,value) constructor to build each option.
Doing it any other way will end in tears. This has nothing to do with
CoffeeScript or JavaScript and everything to do with browsers and the
DOM.