JSFiddle - React, Tailwind, and code Playground

by kapuca

HTML

<script src="http://knockoutjs.com/downloads/knockout-3.2.0.js"></script>
<script src="http://tucujuris.tjap.jus.br/tucujuris/bower_modules/knockout-es5/dist/knockout-es5.min.js"></script>
<voting params="votes: votes"></voting>

<template id="voting-tpl">
    <button data-bind="click: increment ">Up</button>
    <div data-bind="text: votes"></div>
</template>

JavaScript

ko.components.register('voting', {
    viewModel: function(params) {
        var self        = this;
        self.votes      = params.votes;
        
        self.increment  = function(){
            self.votes( self.votes + 1 );
        };
        
        return ko.track(self);
    },
    template: { element: 'voting-tpl' }
});

function Vm(){
    this.votes = 5;
    return ko.track(this);
}

ko.applyBindings(new Vm() );