Data-binding options:
Example:
In this example, the ViewModel is defined specifically for use with the events calendar. It has disabled, eventsData, and appointments properties that are bound in the View. If any of these values change, the widget automatically responds to them. The widget also updates the ViewModel values as it modifies them.
Create a ViewModel:
ViewModel Script |
Copy Code |
---|---|
var viewModel = function () { var self = this; self.disabled = ko.observable(false); self.eventsdata = ko.observableArray([{}, {}, {}, ...]); }; |
Create View with Bound Controls:
View Markup |
Copy Code |
---|---|
<div data-bind="wijevcal: { disabled: disabled, eventsData: eventsData}"> </div> |