Created
October 12, 2012 19:56
-
-
Save treyruncie/3881159 to your computer and use it in GitHub Desktop.
yui3 widget pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YUI.add('mymodule', function (Y) { | |
Y.Mymodule = Y.Base.create('mymodule', Y.Widget, [], { | |
initializer: function (config) { | |
console.log('initializer'); | |
}, | |
renderUI: function (){ | |
console.log('renderUI'); | |
}, | |
bindUI: function (){ | |
console.log('bindUI'); | |
this.after('fooChange', this._bindAfterFooChange); | |
}, | |
syncUI: function (){ | |
console.log('syncUI'); | |
if(this.get('bar')){ | |
this.get('boundingBox').set('text','bar is set to true so some text should go in the boundingBox'); | |
} | |
this.set('foo', true); | |
}, | |
_bindAfterFooChange: function (e){ | |
console.log('prevVal = '+e.prevVal); | |
console.log('newVal = '+e.newVal); | |
} | |
}, { | |
ATTRS: { | |
foo: { | |
value: true | |
}, | |
bar: { | |
value: false | |
} | |
} | |
}); | |
}, '0.1', { requires: ['base','widget'] }); | |
//implementation code | |
YUI().use('mymodule', function (Y) { | |
var module = new Y.Mymodule({boundingBox: '#mynode', bar: true}); | |
module.render(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment