Marty
Marty

Reputation: 65

ui-disable-choice with function

I am trying to disable options in a ui-select using a function in the ui-disable-choice. Calling a function doesn't seem to work. Any ideas on what I am doing wrong?

UI-Select

<ui-select 
            id="affSel--{{seat.sli_no}}"
            class="affSel"
            perf-no ="{{seat.perf_no}}"
            sli-no="{{seat.sli_no}}"
            ng-required="true"
            theme="bootstrap"
            on-select="changedAffiliate(mySeat.seat.sli_no, cartPerf.perf_no, seat.sli_no,seat)">

    <ui-select-match placeholder="-- Select person --">{{$select.selected.fname + ' ' + $select.selected.lname}}</ui-select-match>
    <ui-select-choices repeat="affiliate in affiliates | seatAffTypeFilter:seat.seatAff" 
                        ui-disable-choice="checkDisable(affiliate.customer_no,cartPerf.perf_no, seat.sli_no)">
        <div ng-bind-html="affiliate.fname + ' ' + affiliate.lname"></div>
        <small ng-show="affiliate.disabled">{{AffSelected}}</small>
        <small ng-show="affiliate.validation_pass_age == 'N'">{{invalidAffLbl}}</small>
    </ui-select-choices>
</ui-select>  

Function

$scope.checkDisable = function (customer_no, cur_perf_no, cur_sli_no) {
    $.each($scope.selectedAff, function (i) {
        if (this.customer_no == customer_no && this.perfNo == cur_perf_no && this.sli_no != cur_sli_no) {
            return true;
        } else {
            return false;
        }
    })
}

Upvotes: 2

Views: 1990

Answers (1)

harishr
harishr

Reputation: 18055

try

$scope.checkDisable = function (customer_no, cur_perf_no, cur_sli_no) {
    return false; //true;
}

if this does not work it would mean that function types are not supported, but if it works, then you have code issue...

mostly you are not capturing result of $.each function, from the context it seems you need _.find rather than $.each

Upvotes: 2

Related Questions