Knockout demo for issue #2240
by fastfasterfastest
HTML
<script src="https://unpkg.com/[email protected]/build/output/knockout-latest.debug.js"></script>
<input id="id1" value="initial" data-bind="value: valueProperty">
<div>
Value attribute: <span data-bind="text: valueAttribute"></span>
<input data-bind="value: valueAttribute">
<input data-bind="attr: { value: valueAttribute }">
</div>
<div>
Value property: <span data-bind="text: valueProperty"></span>
<input data-bind="value: valueProperty">
</div>
<p>Log:</p>
<ul data-bind="foreach: log">
<li data-bind="text: $data"></li>
</ul>
JavaScript
function ViewModel() {
var self = this;
var someObject = { x: 1 };
self.valueAttribute = ko.observable(document.getElementById("id1").getAttribute("value"));
self.valueProperty = ko.observable(document.getElementById("id1").value);
self.log = ko.observableArray();
};
ko.options.deferUpdates = false;
ko.applyBindings(new ViewModel());