Plugins

User login
Can't find a Plugin?

Can't find a Plugin you are looking for? Check out the jQuery Wiki page.

Are you a plugin developer? Please move your plugin over to this site.

Website Bug or Feature Request?

Found a bug on the new jQuery Plugin website? Have a feature request?

Submit it to the jQuery Plugin website issue queue to ensure it is noticed!

Bug when setting value on a select element and the select is empty


Project:Field Plug-in
Version:0.7
Component:Code
Category:bug report
Priority:normal
Assigned:DanSwitzer2
Status:closed
Description

Hi,

This is an exeptional case, which does not happen in normal scenarios although it should be handled.

When you set Value on a select element which is empty I receive a js error.

line 313:

this[0].selected = true; // saying this[0] has no properties

as the whole select is empty this make sense.

so I suggest the following modification...
from:
if( bSelectOne && bKeepLooking ){
this[0].selected = true;
}
to:
if( bSelectOne && bKeepLooking ){
if ( this[0] ) this[0].selected = true;
}

I am not sure this is the best way to handle it.

Comments

#1

I tested this under IE6 and FF2 and wasn't able to recreate the problem. I'll put in a check for it though.

#2

Status:active» fixed

Scrath that, I had a bug in my test code. I was able to recreate the problem and I've fixed the problem in v0.8 with:

// if a select-one box and nothing selected, then try to select the default value
if( bSelectOne && bKeepLooking && !!this[0] ){
this[0].selected = true;
}

#3

Assigned to:Anonymous» DanSwitzer2

#4

Status:fixed» closed