knockout example
HTML
<script type="text/javascript"
src="http://cloud.github.com/downloads/SteveSanderson/knockout/knockout-2.0.0.js" charset="utf-8"></script>
<p>First name: <input data-bind="value: firstName" /></p>
<p>Last name: <input data-bind="value: lastName" /></p>
<p>Full name: <strong data-bind="text: fullName"></strong></p>
JavaScript
// This is a simple *viewmodel* - JavaScript that defines the data and behavior of your UI
function AppViewModel() {
this.firstName = ko.observable("Gunvor");
this.lastName = ko.observable("Nilsson");
this.fullName = ko.computed(function() {
return this.firstName() + " " + this.lastName();
}, this);
}
// Activates knockout.js
ko.applyBindings(new AppViewModel());