JSFiddle - React, Tailwind, and code Playground

by darknessm0404

HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div data-bind="init: function(){ if(obsTester()) $($element).css({backgroundColor:'red'}) }">
    <a data-bind="click:btnClick">Click here</a>
</div>

JavaScript

// Binding handler
ko.bindingHandlers.init = {
        init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
            var actions = valueAccessor();
            if (!$.isArray(actions)) {
                actions = [actions];
            }

            actions.forEach(function (action) {
                var previousValueCondition;
                ko.computed(function () {
                    var params = ko.utils.unwrapObservable(action),
                        dataValueCondition,
                        isInitial = ko.computedContext.isInitial();

                    if (typeof params !== 'object') {
                        params = { 'call': params };
                    }

                    // If no condition has been set, condition = true
                    if (params['if'] === undefined) {
                        params['if'] = true;
                        dataValueCondition = true;
                    } else {                    
                        dataValueCondition = ko.utils.unwrapObservable(params['if']);
                        
                        // If it received a function, and not an observable, get the result of the function
                        if (typeof dataValueCondition === 'function' && !ko.isObservable(params['if'])) {
                            dataValueCondition = dataValueCondition();
                        }
                    }
                    
                    debug('evaluating');
                    if (dataValueCondition) {
                        // Prevent executing the function if the value returned by the if binding did not change
                        if (isInitial || previousValueCondition !== dataValueCondition) {
                            ko.bindingHandlers.init.init.__execute(params['call'] || params['then'], viewModel, bindingContext, element, allBindings);
                        }
                        
                    } else if (params['else'] &&...