I need help debugging a jQuery functionality that allows adding options from one selector to another and removing them back from second selector.
It works fine on load, when original copying is made. However if multiple options are added and the “removed” from second selector, there’s some confusion with optgroups.
Someone helped me with this code but my skills aren’t just there to debug this on my own.
Here’s the working code on jsfiddle.
Well, THAT was a bit tricky.
I’ve posted a fix @ http://jsfiddle.net/SwrVK/4/
There were two issues. First, apparently, options can’t have a data attribute. So, I changed everywhere were the javascript was coded .data to .attr.
Secondly, you were assuming the $parent and $optgroup were homogeneous for a selected set of options. They don’t have to be, so I created loops where the $parent and optiongroup were checked for each option.