On 7/11/06, Chris Lear wrote:
* marc-olivier bernard wrote (11/07/06 16:57):
> On 7/11/06, Chris Lear wrote:
>
>> Are you sure it's a Firefox bug? The way the builder code works is very
>> strange... to create an option element, it seems to create a select
>> element, put the option element into it, then fetch the option out of
>> that select element again. The result is that the option is *always*
>> selected. I think it's because firefox is treating it as the only
>> element in the select list, which means it must be selected. [When I run
>> your code, the last element in the list is selected, rather than the
>> first. If I debug the value of the "selected" attribute, it's "selected"
>> for all of them]
>
> Are you speaking from the code at
> http://bugzilla.mozilla.org/show_bug.cgi?id=300016#c10 ?
No. I was talking about the code you posted using scriptaculous.
Then, I don't see where the Scriptaculous code is wrong... I think it
is due to the underlying bug. That code gives the right DOM Tree with
DOM Inspector.
I agree. I don't think it should. I hadn't looked at the bug report when
I posted to this list. Then I looked at the bug, and saw that you'd
presented your code differently there. I thought it would be worth
posting a working version there in case it's useful information for the
developers.
I now agree that there is a bug, but there's also a workaround, and the
builder should probably use the workaround if possible. I'm also
mystified as to why the builder works in the odd way it does.
I found another workaround, simply use the HTML Form DOM Interface to
set the selectedIndex to the right one:
<script type="text/javascript">
var td_Fieldset ;
td_Fieldset = Builder.node('fieldset',[
Builder.node('legend',"Information Set")
]);
td_Fieldset.appendChild(
Builder.node('div',[
Builder.node('span',"Descriptive Title"),
Builder.node('select',{id:'anyId'},[
Builder.node('option',{value:'any'},"any"),
Builder.node('option',{value:'all',selected:'selected'},"all"),
Builder.node('option',{value:'none'},"none")
])
])
);
$('modification1').appendChild(td_Fieldset);
// right here I use the HTML Form DOM Interface
$('anyId').selectedIndex = 1; // <----
</script>
--
Marc-Olivier BERNARD
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs