JSFiddle - React, Tailwind, and code Playground

by ducas

HTML

<script src="http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.1.0.js"></script>
<script src="https://raw.github.com/SteveSanderson/knockout.mapping/master/build/output/knockout.mapping-latest.js"></script>
<ul id="testList" data-bind="template: { name: templateName, foreach: items }"></ul>

<script type="text/html" id="testTemplate">
    <li data-bind="text:text"></li>
</script>

JavaScript

$(function () {
    var vm = ko.mapping.fromJS({
        items: [{
            text: "Item 1"
        }, {
            text: "Item 2"
        }, {
            text: "Item 3"
        }, {
            text: "Item 4"
        }, {
            text: "Item 5"
        }]
    }),
        view = $("#testList").get(0);
    
    vm.templateName = function (item) {
        console.log(item.text());
        return 'testTemplate';
    };
    
    ko.applyBindings(vm, view);
});