markjs / jquery-dependent-selects

A jQuery plugin to allow multi-level select boxes that degrade gracefully.
http://markjs.github.com/jquery-dependent-selects/
MIT License
56 stars 23 forks source link

Bug preselecting an option #14

Open savermsx opened 10 years ago

savermsx commented 10 years ago

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!

markjs commented 9 years ago

Hey @savermsx! I've just had this repo transferred back to me from my previous employer (I originally created it while working there). Over the coming days and weeks I'll be catching up with all the issues and looking into personally maintaining this in the long run.

Sorry that your comment has gone un-replied for so long, but now it's back in my hands I'll try my best to stay on top of it all.