On Thursday 18 January 2007 03:59, Selanit wrote:
I've been experiencing some irregularities with Prototype 1.4.0's
Insertion objects and <select> boxes. The same code yields different
outcomes with different browsers. Here's a test case:
http://dev.laits.utexas.edu/medievalmap/testa.html
There's a full write-up in the test case - but basically, I'm inserting
a new option (<option value="1">apple</option>).
- In Firefox 2 (and presumably older versions), it works right.
- In Opera 9, the </option> is omitted.
- In IE 6, the <option value="1"> is omitted.
I haven't got a copy of IE 7 handy, nor do I have Safari, or I'd have
tested those too.
It doesn't work on IE7, and does work on Safari (v.2.0.4) FWIW. No surprises
there, then.
Is there some obvious way to fix this that I've missed? Any
suggestions would be most welcome.
Select elements in IE are a law unto themselves - they're implemented as
top-level GDI elements or something like that (my grasp of Windows graphics
isn't up to scratch), which can cause them to 'punch through' DIVs that
overlap them, etc. The Prototype Insertion objects are working with generic
DOM elements and methods (e.g. insertBefore()) under the hood, which I
suspect just don't work for SELECT elements in IE. I think if you try to add
options to a select using plain old innerHTML in IE, it messes up too (but
adding an entire new SELECT element using innerHTML is OK).
The easiest way to fix it is probably just to use the select elements options
property, and the add() method to add a new option object, something like:
var sel=$("TestSelect");
sel.add(new Option("apple",1));
This are DOM 1 standard stuff, supported in all browsers AFAIK.
HTH
Dave
----------------------
Author
Ajax in Action http://manning.com/crane
Ajax in Practice http://manning.com/crane2
Prototype & Scriptaculous Quickly http://manning.com/crane3
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on
Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---