Created
March 27, 2010 19:37
-
-
Save ericf/346309 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // ... | |
| Y.extend(MyPage, Y.Base, { | |
| components : { | |
| myComponent : { | |
| requires : ['overlay'], | |
| initializer : '_initMyComponent' | |
| } | |
| }, | |
| initializer : function (config) { | |
| this.on('initComponents', function(e){ | |
| if (Y.one('#foo')) { | |
| e.components.push('myComponent'); | |
| // now if #foo exits, | |
| // myComponent will be "eagerly" initialized | |
| } | |
| }); | |
| Y.one('body').on('click', function(e){ | |
| this.getComponent('myComponent', function(mc){ | |
| // myComponent is for sure initialized. | |
| mc.show(); | |
| }); | |
| }); | |
| }, | |
| _initMyComponent : function () { | |
| // Y.Overlay and all of it's dependencies | |
| // have been added to the YUI instance at this point. | |
| return (new Y.Overlay({ render: true })); | |
| } | |
| }); | |
| // ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment