Skip to content

Instantly share code, notes, and snippets.

@ryanjduffy
Created September 7, 2011 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanjduffy/1199671 to your computer and use it in GitHub Desktop.
Save ryanjduffy/1199671 to your computer and use it in GitHub Desktop.
Reset kind to published properties
var _Example = {
name:"com.technisode.example.App",
kind:"Control",
published:{
a:1,
b:2,
c:3
},
components:[
{kind:"IntegerPicker", name:"aPicker", label:"A"},
{kind:"IntegerPicker", name:"bPicker", label:"B"},
{kind:"IntegerPicker", name:"cPicker", label:"C"},
{kind:"Button", onclick:"resetClicked"}
],
create:function() {
this.inherited(arguments);
this.aChanged();
this.bChanged();
this.cChanged();
},
aChanged:function() {
this.$.aPicker.setValue(this.a);
},
bChanged:function() {
this.$.bPicker.setValue(this.b);
},
cChanged:function() {
this.$.cPicker.setValue(this.c);
},
reset:function(property) {
if(property) {
enyo.call(this, "set" + enyo.cap(property), [this.published[property]]);
} else {
for(var k in this.published) {
enyo.call(this, "set" + enyo.cap(k), [this.published[k]]);
}
}
},
resetClicked:function() {
this.reset();
}
}
enyo.kind(_Example);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment