jQuery-Selectric
jQuery-Selectric copied to clipboard
Incorrect result when optGroup with multiple
an error value get when init a multiple select with optGroup.
I add following code in public/index.html
<div class="item">
<select multiple>
<option>Select with optgroup and multiple</option>
<optgroup label="Group 1">
<option>Option 1.1</option>
</optgroup>
<optgroup label="Group 2">
<option selected>Option 2.1</option>
<option selected>Option 2.2</option>
</optgroup>
<optgroup label="Group 3" disabled>
<option>Option 3.1</option>
<option>Option 3.2</option>
<option>Option 3.3</option>
</optgroup>
</select>
</div>
And get an error value after init, like this
Is this an expected performance? Thank u for viewing this issue!
The way to calculate index of option which seleted may be not fit for this place.
if ( $selected.length > 1 && _this.state.multiple ) {
selectedIndex = [];
$selected.each(function() {
selectedIndex.push($(this).index());
});
}
I modified it :
if ( $selected.length > 1 && _this.state.multiple ) {
selectedIndex = [];
$selected.each(function() {
selectedIndex.push($(_this.$element.find("option")).index(this));
});
}
Wish u can see this and give me a reply, thank u.
Hey, I just created a pull-request based on your work.
It works like a charm here. Hope the maintainer will merge it soon.
In case you want to use this fork in one project via npm :
npm install --save github:Jjoye/jQuery-Selectric
Congrats 💪