mike
mike

Reputation: 47

Ui-select : Search box not shown to search when data is an empty array

I have a ui-select that uses refresh to fetch data from server whenever a user inserts a char in input box (search box). the issue is that the input box is not available when data is an empty array, so the user cannot search to fetch data. Needless to say that I only want to present data when the user search for it.

This only happens with theme "select2". With boostrap theme it is working.

<ui-select id="client" name="client" ng-model="search._client" theme="select2" ng-change="loadInventories()">
<ui-select-match ng-show="$select.isEmpty()" allow-clear="true" placeholder="{{'CLIENT' | translate}}">{{$select.selected.name | translate}}</ui-select-match>
<ui-select-choices repeat="client in filtered_clients | filter: $select.search | orderBy:'name' | limitTo: 5"  refresh="load_filtred_clients($select.search)" refresh-delay="0">
 <div>{{client.name | translate}}</div>
    </ui-select-choices>
    </ui-select>

is there a way to show the searchbox wwhen the array is empty?

Upvotes: 0

Views: 530

Answers (1)

user11390576
user11390576

Reputation:

It sounds like the 'select2' theme is adding the disabled HTML attribute to your search box when the array is empty.

You could try locating the code where the 'select2' theme adds the disable attribute, and edit it (not recommended) or override it in some way:

element.removeAttribute("disabled");

Upvotes: 1

Related Questions