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

select2 with optgroups doesnt get initialized #57

@animator013

Description

@animator013

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions