JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://knockoutjs.com/downloads/knockout-2.2.0.js"></script>
<input type="text" data-bind="value: firstName" />
<input type="text" data-bind="value: lastName" />
<span data-bind="text: fullName"></span>
JavaScript
var HomeViewModel = function(config, $, undefined) {
if (!this instanceof HomeViewModel) {
return new HomeViewModel(config, $, undefined);
}
this.firstName = ko.observable(config.firstName);
this.lastName = ko.observable(config.lastName);
};
HomeViewModel.prototype.fullName = function() {
return ko.computed(function() {
return this.firstName() + " " + this.lastName();
}, this);
};
var model = new HomeViewModel({
firstName: "John",
lastName: "Smith"
}, jQuery);
ko.applyBindings(model);