Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Knockout data-bind disable. With two conditions

Is it possible to use || operator in disable like this:

data-bind="click: createSubActivity, disable: isDeliveryHistory || isTimeAndMaterialLocked"

I have tried, but it seems like it doesn't work.

like image 522
LadyBug Avatar asked Mar 31 '14 10:03

LadyBug


People also ask

What is data bind Knockout?

Knockout's declarative binding system provides a concise and powerful way to link data to the UI. It's generally easy and obvious to bind to simple data properties or to use a single binding.

Can we have multiple Knockout models on a single page?

Knockout now supports multiple model binding. The ko. applyBindings() method takes an optional parameter - the element and its descendants to which the binding will be activated. This restricts the activation to the element with ID someElementId and its descendants.

What is HTML Databind?

The "data-bind" attribute contains a collection of comma-separated options for how Knockout should bind a view model property to an HTML element. The two examples above use only a single option: the "value" binding handler.


1 Answers

If isDeliveryHistory and isTimeAndMaterialLocked are observables, you should use them like this:

data-bind="click: createSubActivity, disable: isDeliveryHistory() || isTimeAndMaterialLocked()"
like image 172
Rob Avatar answered Nov 08 '22 19:11

Rob