JSFiddle - React, Tailwind, and code Playground

by castor_4bit

HTML

<script src="https://rawgit.com/rniemeyer/knockout-postbox/master/build/knockout-postbox.js"></script>
<div id="aikatsu_counter">
  <span data-bind="text: count()"></span> 回
</div>
<div id="aikatsu_action">
  <input data-bind="click: action" type="button" value="アイカツする" />
  <span data-bind="text: result()"></span>
</div>

JavaScript

var aikatsuModel = function() {
  var self = this;
  self.count = ko.observable(0).syncWith("aikatsu_count");
  self.result = ko.observable("");
  self.action = function() {
    self.count( self.count() + 1 );
    self.result( self.result() + "アイ!カツ! " );
  }
}
ko.applyBindings(new aikatsuModel(), document.getElementById("aikatsu_action"));


var summaryModel = function() {
  var self = this;
  self.count = ko.observable(0).syncWith("aikatsu_count");
}
ko.applyBindings(new summaryModel(), document.getElementById("aikatsu_counter"));