Wijmo User Guide > Concepts > Knockout > Two-Way Live Binding > KO Editor Binding |
Data-binding options:
Example:
In this example, the ViewModel is defined specifically for use with the editor. It has disabled, editorMode, showPathSelector, showFooter, and mode 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. The editor will appear in split mode so that both the editor and code will be visible, and the simple toolbar will be shown.
Create a ViewModel:
ViewModel Script |
Copy Code
|
---|---|
var viewModel = function () { var self = this; self.disabled = ko.observable(false); self.editorMode = ko.observable('wysiwyg'); self.showPathSelector = ko.observable(true); self.mode = ko.observable('ribbon'); self.showFooter = ko.observable(true); }; |
Create View with Bound Controls:
View Markup |
Copy Code
|
---|---|
<textarea data-bind="wijeditor: {disabled: disabled, editorMode: editorMode, mode: mode}" style="width: 756px; height: 475px;"> <h1> JavaScript</h1> <p> <img src=http://cdn.wijmo.com/images/200px-JavaScript-logo.png alt="JavaScript-logo.png" height="200" width="200" style="float: left; margin: 10px"> JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles. </p> </textarea> |