Hi,
I'm feeling really stupid about this because I feel I might be doing
something wrong here. I am adding options to a select element like
follows:
var select = new Element('select');
select.adopt(new Element('option',{
'text' : 'text',
'value' : 'value'
}));
Now, when I try to iterate over the elements like this, I get nothing:
for(var i in select.options){
alert(i);
}
Furthermore, if I debug like this:
console.log(select.options);
I get an empty array in the Chrome inspector console...
BUT... if I debug like this:
console.log(select.options.length);
I get "1"... and if I do this:
console.log(select.options[0]);
I get this in the console!:
<option value="set">set</option>
The selectedIndex property also sets correctly.
console.log(select.selectedIndex); //Displays "0"
...so it looks like I'm dealing with some sort of quanum array,
haha... but seriously, my head is spinning.
All I can figure out is either I'm not doing this the right way, or,
when a select adopts an option with mootools the options array is not
being modified properly... but the browser kind of tries to.
Please help, I need exactly this behavior to work: setting/iterating
programmatically.
Thanks in advance.
Regards,
David