JSFiddle - React, Tailwind, and code Playground

by rdvornov

HTML

<script src="http://cdnjs.cloudflare.com/ajax/libs/basis.js/1.2.1/basis.min.js"></script>

JavaScript

var MyType = basis.entity.createType('MyType', {
    id: basis.entity.IntId,
    title: String
});

MyType.extendClass({
    save: function() {
        alert('save');
    }
});

var ItemList = basis.ui.Node.subclass({    
    template: '<li event-click="save">{title}</li>',
    binding: {
        title: 'data:title'
    },
    action: {
        save: function () {
            // this.delegate -> MyType instance
            // this.target -> MyType instance
            // т.к. MyType.entityClass.prototype.target === true
            // лучше использовать target так как цепочка может быть длинной
            this.target.save();
        }
    }        
});
var List = basis.ui.Node.subclass({
    container: document.body,
    service: null,
    template: '<ul/>',
    childClass: ItemList,
    childNodes: [
        MyType({ title: 'foo' }),  // это эквивалентно { delegate: MyType({ .. }) }
        MyType({ title: 'bar' })
    ]
});
new List();