$(document).ready(function() {
var viewModel = function() {
var cel = ko.observable();
var fah = ko.computed({
read: function() {
return (cel() * 9 / 5) + 32;
},
write: function(value) {
cel(((value - 32) / 9) * 5);
},
owner: this
});
return {
cel: cel,
fah: fah
};
}();
ko.applyBindings(viewModel);
});
<span>Temperature in Celcius : </span><input data-bind="value:cel" />
<br /><br/>
<span>Temperature in Fahrenheit : </span><input data-bind="value:fah" />
External resources loaded into this fiddle: