具有多个选择的JQuery Select2自动完成下拉列表

时间:2018-05-18 09:51:48

标签: angularjs jquery-select2

这里使用带有多个选择的JQuery Select 2自动完成下拉列表。

当它被单一使用时它工作正常,就像这样

Only one dropdown

但是当它被多个Auto完全不工作时使用时,就像这样

More than one dropdown

<div class="col-lg-6" ng-repeat="locationtype in allLocationTypes">
    <b><label ng-bind="locationtype.Type"></label></b>
    <div class="form-group">
        <select id="LocationMapID" multiple="multiple" class="form-control" placeholder="Select Location" style="width:100%">
            <option value="" disabled="disabled">--Select Location--</option>
            <option  ng-repeat="location in allLocations | filter :filterLocations(locationtype.ID) " value="{{location.ChildLocationID}}">{{location.ParentLocation + '-' + location.ChildLocation}}</option>
        </select>
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

我之前曾遇到过这个问题

为解决这个问题,我为每个select2框设置了Uniq ID

<div class="col-lg-6" ng-repeat="locationtype in allLocationTypes">
    <b><label ng-bind="locationtype.Type"></label></b>
    <div class="form-group">
        <select id="LocationMapID_{{locationtype.Type}}" multiple="multiple" class="form-control" placeholder="Select Location" style="width:100%">
            <option value="" disabled="disabled">--Select Location--</option>
            <option  ng-repeat="location in allLocations | filter :filterLocations(locationtype.ID) " value="{{location.ChildLocationID}}">{{location.ParentLocation + '-' + location.ChildLocation}}</option>
        </select>
    </div>
</div>