JSFiddle - React, Tailwind, and code Playground
by lynnaloo
JavaScript
var myModel = {
attributes: {},
save: function (key, value, options) {
var that = this;
// let's start storing these values in the attributes object,
// more or less like backbone does.
this.attributes[key] = value;
setTimeout(function() {
// myModel assumes that options is an object, and that
// options.success is a function, and that THAT'S where the view
// is putting the callback.
options.success(that.attributes);
}, 1000);
}
};
enyo.kind({
name: "FooTest",
published: {
value: null
},
components: [{
kind: "onyx.Button",
content: "Set Baz",
ontap: "run"
}],
run: function () {
var printItOut = function (value) {
alert("Model contents are now " + JSON.stringify(value));
};
this.getValue().save("baz", "foo", {success: printItOut});
}
});
var fooTest = new FooTest();
fooTest.setValue(myModel);
fooTest.renderInto(document.body);