Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

select2 with optgroups doesnt get initialized #57

Closed
animator013 opened this issue Aug 15, 2013 · 0 comments
Closed

select2 with optgroups doesnt get initialized #57

animator013 opened this issue Aug 15, 2013 · 0 comments

Comments

@animator013
Copy link

Hello there,

when I use

<select ng-disabled="_disabled" ng-model="all.categories" multiple="multiple" ui-select2="{ allowClear: true,width: '600px'}">
    <optgroup ng-repeat="category in categories" label="{{category.name}}">
        <option ng-repeat="item in category.children" value="{{item.id}}">{{item.name}}</option>
    </optgroup>
</select>

with latest select2 plugin there is a problem that i dont get selected items from model. I can see that all items are in the options, i can select them, they appear in the select but i cant see already chosen items from model (after refresh). So it wont get initialized.

I found a solution to change line:

repeatOption = tElm.find('option[ng-repeat], option[data-ng-repeat]');

to

repeatOption = tElm.find('optgroup[ng-repeat], optgroup[data-ng-repeat], option[ng-repeat], option[data-ng-repeat]');

so it watches also for ng-repeat in optgroup.

Dont know if it is a clean solution or not but it started to work with it. Can you advise ?

P.S.: I also looked at issue #8 where was said to update to latest version. But it didnt help.

ProLoser added a commit that referenced this issue Jan 28, 2014
Fixed #57 - now select2 initializes also for optgroup
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant