knockout dependentObservables do not trigger notifications
See https://groups.google.com/forum/#!topic/knockoutjs/bX8ze5S1w8o
HTML
<script src="https://github.com/downloads/SteveSanderson/knockout/knockout-1.2.1.js"></script>
<html>
<body>
Updates from 1 will not be shown in 2 because knockout dependentObservables do
not tigger notifications on write. See <a target="_blank" href="https://groups.google.com/forum/#!topic/knockoutjs/bX8ze5S1w8o">discussion</a>.
<hr/>
Dependent Observable on testValue 1 <input type="text" data-bind="value: testDependantObservable" \>
<br />
Dependent Observable on testValue 2 <input type="text" data-bind="value: testDependantObservable" \>
<br />
Actual testValue<input id="actualTestValue" type="text"\>
</body>
</html>
JavaScript
$(document).ready(function () {
var testValue = 1;
$("#actualTestValue").val(testValue);
var viewModel = {
testDependantObservable: ko.dependentObservable({
read: function() {
return testValue;
},
write: function (value) {
testValue = value;
$("#actualTestValue").val(testValue);
}
})
}
ko.applyBindings(viewModel);
});