Skip to content

Bug preselecting an option #14

@savermsx

Description

@savermsx

If you try to preselect the first or second item you will see don't work:

< select >
< option value='A1>B1' selected='selected' >A1 || B1< /option>
< option value='A1>B2' >A1 || B2< /option >
< option value='A1>B3' >A1 || B3< /option >
< /select >

Only work for the last item in each subselect.

That's because an error on selectPreSelected function.

When you found the selected item you do this:

return $(this).attr('selected', 'selected');

But this is not the way to exit from a jQuery Each, so program continue searching until the end.

The way is using return false;

I fixed the problem changing to:

$(this).attr('selected', 'selected');
return false;

Thanks! I like your work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions