You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to use the multiple select part of select2 with optgroups and options.I planned on each option having an id, and then each optgroup's id being the list of those id's.
ex:
id: my_id_one, my_id_two, text: my_optgroup_one
id: my_id_one, text: one
id: my_id_two, text: two
id: my_two_a, my_two_b, my_two_c, text:my_optgroup_two
id: my_two_a, text: a
id: my_two_b, text: b
id: my_two_c, text: c
This works great! However, when I go ahead and click the little "x" to unselect an optgroup, all the children options are removed from the select list and are unable to be selected.
Another example (given the template I made above):
Select a, Unselect a => Works!
Select my_optgroup_a, check val of select box, val is my_two_a, my_two_b, my_two_c, Unselect my_optgroup_a => a, b, and c are no longer selectable from the list.
This works if I make my own custom separator for the ID's, but then I'd have to parse out and replace the select2 separator with my custom separator.
I imagine in the code of select2, it goes ahead and does a remove on the specified ID. Since, in my case the ID is a list of comma separated ID's, it makes sense that all the specified ID's would be removed from the select list.
Is there a suggestion, or an alternative way I should be looking at to accomplish my goal?
Thank you!
The text was updated successfully, but these errors were encountered:
Looking at the code a bit more closely, it would seem related to line #3168 -
if (indexOf(id, val) >= 0) {
choice.addClass("select2-selected");
// mark all children of the selected parent as selected
choice.find(".select2-result-selectable").addClass("select2-selected");
}
As the id is a string of other id's, and it looks like val is an array of those id's. Asking if, the id's found with select2 classes are contained inside the val array.
Hello!
I wanted to use the multiple select part of select2 with optgroups and options.I planned on each option having an id, and then each optgroup's id being the list of those id's.
ex:
This works great! However, when I go ahead and click the little "x" to unselect an optgroup, all the children options are removed from the select list and are unable to be selected.
Another example (given the template I made above):
This works if I make my own custom separator for the ID's, but then I'd have to parse out and replace the select2 separator with my custom separator.
I imagine in the code of select2, it goes ahead and does a remove on the specified ID. Since, in my case the ID is a list of comma separated ID's, it makes sense that all the specified ID's would be removed from the select list.
Is there a suggestion, or an alternative way I should be looking at to accomplish my goal?
Thank you!
The text was updated successfully, but these errors were encountered: