Elliot
Elliot

Reputation: 13835

Knockoutjs visible binding with || or?

I want to do something basic like:

data-bind="visible: x || y"

showing if either x or y is set to true

Everything I've tried has failed so far though.

Upvotes: 1

Views: 638

Answers (2)

user24359
user24359

Reputation:

When using observables in a formula like that, you need to call them as functions.

data-bind="visible: x() || y()"

Upvotes: 0

Miroslav Popovic
Miroslav Popovic

Reputation: 12128

If x and y are observable properties then you need to call them as methods:

data-bind="visible: x() || y()"

Upvotes: 5

Related Questions