Hi!

I recently came across the same problem. It seems that IE8 sets
'selected' attribute for all options in select-boxes by default to
false.

Assume you have a select-box:

<select name="abc">
  <option name="1">1</option>
</select>

When you load the page, obviously this select will be visible and the
first (default) option will be selected. And in any browser (but IE8)
when you read it's 'selected' attribute, it will be true:

$('option[name=1]').attr('selected') == true

IE8 behaves in a different way and sets it by default to false. When
you click on a select box and choose some option manually, the
behavior of the browser goes back to normal, and correct option has
selected==true.


This behavior breaks serializeArray() - it does not gather information
about select-boxes with default value. I did a simple workaround for
my personal usage, but I'm not sure if it's "pretty" (well... I'm sure
it's not):

in the file jquery-1.3.2.js
line: 438:
if ( option.selected || (jQuery.browser.msie && jQuery.browser.version
== 8) ) {

context, lines 435 - 451:
                                        for ( var i = one ? index : 0, max = 
one ? index + 1 :
options.length; i < max; i++ ) {
                                                var option = options[ i ];

                                                if ( option.selected || 
(jQuery.browser.msie &&
jQuery.browser.version == 8) ) {
                                                        // Get the specifc 
value for the option
                                                        value = 
jQuery(option).val();

                                                        // We don't need an 
array for one selects
                                                        if ( one )
                                                                return value;

                                                        // Multi-Selects return 
an array
                                                        values.push( value );
                                                }
                                        }

                                        return values;



Hope I made myself clear,

Regards,

Rafał Zarajczyk






On 15 Paź, 14:19, gregory tomlinson <gregory.tomlin...@gmail.com>
wrote:
> Hi Saurus. Your example appears to be
> incomplete. Maybe you could zip up an example and attach it?
> thanks
> -gregory
>
>
>
> On Wed, Oct 14, 2009 at 8:37 PM, Saurus <pao...@gmail.com> wrote:
>
> > sorry, i misclicked submit too soon!
>
> > anyone know about these problems with unchanged select boxes not being
> > included in the
> > array returned by serializeArray?
>
> > On Oct 14, 11:18 am, Saurus <pao...@gmail.com> wrote:
> > > I am seeing some strange behaviour from IE8 using serializeArray in
> > > Jquery 1.3.2 and was wondering if someone could explain why this is
> > > happening.
>
> > > Working with IE8 I do not get unchanged select boxes included in the
> > > object returned by serializeArray.
>
> > > here is my html:
>
> > > <form id="frm" action="Default.aspx" method="post">
> > >    <table>
>
> > >    </table>
> > > </form>
>
> > > using IE8 version 8.0.6001.18702
>
> --
> Ned Flanders:  "I wish we lived in a place more like the America of
> yesteryear that only exists in the brains of us Republicans."
> ________________________________
>
> Digi Whack - Permanent graffiti in a digital worldhttp://digiwhack.me

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to