JSFiddle - React, Tailwind, and code Playground

by rniemeyer

HTML

<script id="template1" type="text/template">
   <h3>Template 1</h3>
   <button id="templButton" data-bind="click: swap">Go to template 2</button>
</script>

<script id="template2" type="text/template">
   <h3>Template 2</h3>
</script>

<div data-bind="template: { name: 'template1', 'if': one }"></div>
<div data-bind="template: { name: 'template2', ifnot: one }"></div>

JavaScript

ko.applyBindings({
    one: ko.observable(true),
    swap: function() {
       this.one(false);
    }
});