Data-binding options:
Example:
In this example, the ViewModel is defined specifically for use with the input date. It has val and disabled properties that are bound in the View. If any of these values change, the widgets automatically respond to them. The widgets also update the ViewModel values as they modify them.
Create a ViewModel:
ViewModel Script |
Copy Code |
---|---|
var viewModel = function () { var self = this; self.val = ko.observable (new Date ('1/1/2014')); self.disabled = ko.observable (false);}; |
Create View with Bound Controls:
View Markup |
Copy Code |
---|---|
<input data-bind="wijinputdate: {date: val, disabled: disabled}" /> |