
struts2-jquery - issue #201
Dynamic select boxes will not set selected option in IE6
(This is for feature requests and bugs in Struts2 jQuery Plugin - for getting help, please use the User Group. http://groups.google.com/group/struts2-jquery )
What steps will reproduce the problem? 1. Create a page with a <sj:select> box. 2. Use the value="" attribute to select a value other than the first item in the list. 3. Load the page in IE6.
What is the expected output? What do you see instead? I expect to see the option which matches the value="" attribute selected when the select box loads. This works in Firefox 3, IE7, and IE8. However, in IE6, I see the select box defaulting to the first item in the list (no selected value). This was working with plugin version 2.0.0.
Which struts2 version? 2.1.8.1
Which struts2-jquery plugin version? 2.2.0
Please provide any additional information below.
If I add an alert() box immediately before setting option.selected = true (line 248 in the current revision), I can see that the Javascript code is trying to select the value properly. Furthermore, the mere addition of the alert box ensures that IE6 renders the box with the appropriate value selected! (the expected behavior) This implies to me that there is some sort of internal race condition going on in IE6 that is beyond our control.
I compared the Javascript code with the 2.0.0 version and I found that the only change was the line: container[0].length = 0; was changed to: container.children().remove();
I was able to correct the problem by reverting this line to the original version.
It's worth noting that both of these have the effect of clearing the select box, but the latter is recommended by DOM standards as the .length property is really supposed to be read-only (though IE and FF allow you to write to it). So I understand the rationale for the change. But in IE6, the latter results in a race condition.
Comment #1
Posted on Jun 9, 2010 by Swift Lion(No comment was entered for this change.)
Comment #2
Posted on Jun 9, 2010 by Swift Lionhttp://code.google.com/p/struts2-jquery/source/detail?r=1054
Comment #3
Posted on Jun 17, 2010 by Swift Lion(No comment was entered for this change.)
Status: Fixed
Labels:
Type-Defect
Priority-Medium
Component-Plugin
Milestone-2.2.1