Data-binding options:
Example:
In this example, the ViewModel is defined specifically for use with the dialog. It has disabled, autoOpen, draggable, model, and resizable properties that are bound in the View. If any of these values change, then the widgets will 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.disabled = ko.observable(false); self.autoOpen = ko.observable(true); self.draggable = ko.observable(true); self.modal = ko.observable(false); self.resizable = ko.observable(true); }; |
Create View with Bound Controls:
View Markup |
Copy Code |
---|---|
<div id="dialog" data-bind="wijdialog: { disabled: disabled, autoOpen: autoOpen, draggable: draggable, modal: modal, resizable: resizable }" title="Basic dialog"> |