JSFiddle - React, Tailwind, and code Playground
by piercove
HTML
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.0.min.js"></script>
<div id="result"></div>
JavaScript
var ViewModel;
// Create an observable view model object.
var person = function() {
var self = this;
self.firstName = ko.observable("John");
self.lastName = ko.observable("DeVight");
// Create a dependent method (calculated field).
self.fullName = ko.computed(function () {
return self.firstName() + " " + self.lastName();
});
};
// Match to the global JS object
ViewModel = new person();
// Bind the view model to the personFields element.
ko.applyBindings(ViewModel, document.getElementById("result"));
var fullName = ViewModel.fullName();
$("#result").html(fullName);