Skip to content

Instantly share code, notes, and snippets.

@ericf
Created December 16, 2010 05:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericf/743091 to your computer and use it in GitHub Desktop.
Save ericf/743091 to your computer and use it in GitHub Desktop.
Y.MyWidget = Y.Base.create('myWidget', Y.Widget, [], {
// *** Prototype *** //
bindUI : function () {
this.after('myAttrChange', this._afterMyAttrChange);
},
syncUI : function () {
this._uiSetMyAttr(this.get('myAttr'));
},
// *** Private *** //
_uiSetMyAttr : function (val) {
if (val) {
this.get('contentBox').addClass('cool');
} else {
this.get('contentBox').removeClass('cool');
}
},
_afterMyAttrChange : function (e) {
this._uiSetMyAttr(e.newVal);
}
}, {
// *** Static *** //
ATTRS : {
myAttr : {
value : true,
validator : Y.Lang.isBoolean
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment