Hi,
The `Option` constructor is provided by the browser and returns an
HTMLOptionElement instance; since IE6 and IE7 don't allow prototypical
extensions to these things[1], you have to run it through `$` (or
`Element.extend`) to extend the element:
function optionAdder(s) {
var optIdx = $('mySelect').options.length;
$('mySelect').options[optIdx] = $(new Option(s.text, s.val)); // <==
Change is here
$('mySelect').options[optIdx].store("meta", s.meta);
}
In contrast to `Option`, the `Element` constructor is provided by
Prototype and does this for you automatically.
[1] http://prototypejs.org/learn/extensions
HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com
On May 28, 4:30 pm, blechler <[email protected]> wrote:
> Whilst flogging the horse that should be dead (IE7); I discovered that
> I was unable to use Element.store on the options within a select:
>
> function optionAdder(s) {
> var optIdx = $('mySelect').options.length;
> $('mySelect').options[optIdx] = new Option(s.text, s.val);
> $('mySelect').options[optIdx].store("meta", s.meta); //<----
> Object doesn't support this property or method
>
> }
>
> The above function works in IE8. This next function, on the other
> hand, does work in IE7:
>
> function optionAdder(s) {
> $('mySelect').appendChild(new Element('option', {"value":s.val,
> "meta":s.meta}).update(s.text));
>
> }
>
> In this case I use readAttribute instead of the retrieve method. Can
> anyone offer insight as to why store doesn't work?
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.