JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://github.com/downloads/SteveSanderson/knockout/knockout-2.0.0.js"></script>
<ul data-bind="foreach: Items">
<li>
<button data-bind="click: setTextColor, text: 'Color: ' + color"></button>
</li>
</ul>
CSS
li { padding: 2px 10px; }
JavaScript
var Item = function(color) {
this.color = String(color);
this.setTextColor = function(item, event) {
$(event.target).css('background', color);
};
};
ko.applyBindings(new function() {
this.Items = ko.observableArray([
new Item('red'),
new Item('blue'),
new Item('green')
]);
}());