JSFiddle - React, Tailwind, and code Playground

by ericf

JavaScript

//Open console then run the script
YUI().use('model', function (Y) {
    var model = new Y.Model({
        id   : 1,
        name : 'foo',
        stuff: ['bar', 'baz']
    });
    
    model.sync = function (action, data, callback) {
        callback(null, this.getAttrs());
    };
    
    model.on('change', function (e) {
        if (!e.src === 'save') {
            Y.log('saving');    
            this.save({src: 'save'});
        }
    });
    
    model.set('name', 'test');
});