JSFiddle - React, Tailwind, and code Playground
by StevenSanderson
HTML
<script src="http://jshost.googlecode.com/hg/knockout-1.3pre.js"></script>
<h3>Products</h3>
<ul data-bind="foreach: products">
<li>
<strong data-bind="text: name"></strong>
<em data-bind="if: manufacturer">
— made by <span data-bind="text: manufacturer.company"></span>
</em>
</li>
</ul>
CSS
body { font-family: Arial, Helvetica }
JavaScript
function appViewModel() {
this.products = ko.observableArray([
{ name: "XBox", manufacturer: { company: "Microsoft" } },
{ name: "PlayStation", manufacturer: { company: "Sony" } },
{ name: "Banana", manufacturer: null },
{ name: "Wii", manufacturer: { company: "Nintendo" } }
]);
};
ko.applyBindings(new appViewModel());