Pratik Bhoir
Pratik Bhoir

Reputation: 2144

ko.computed by not using values in Viewmodel od knockout

is it possible to us ko.computed by using values which are not observable in viewmodel.

    self.EnableSave = ko.computed(function () {

        if ($('#PoolName').val().toString().trim().length > 0 && $('#Description').val().toString().trim().length > 0 && self.MatrixList().length > 0) {
            return true;
        }
        else {
            return false;
        }
    });

Upvotes: 0

Views: 59

Answers (1)

azurelogic
azurelogic

Reputation: 786

I don't see any reason you couldn't use non-observables in a computed. However, only changes to observables would trigger the computed to fire. In this case, the computed would only reevaluate when MatrixList changes.

Upvotes: 1

Related Questions