Data-binding options:
Example:
In this example, the ViewModel is defined specifically for use with the textbox. It has a disabled option that is bound in the View. If this value changes, the widgets automatically respond. The widgets also update the ViewModel values as they modify them.
Create a ViewModel:
ViewModel Script |
Copy Code |
---|---|
var viewModel = function () { this.disabled = ko.observable(false); }; |
Create View with Bound Controls:
View Markup |
Copy Code |
---|---|
<input data-bind="value: val, wijtextbox: {disabled: disabled}" style="width: 200px;" /> |