Skip to content

Instantly share code, notes, and snippets.

@ericf
Created March 27, 2010 19:37
Show Gist options
  • Select an option

  • Save ericf/346309 to your computer and use it in GitHub Desktop.

Select an option

Save ericf/346309 to your computer and use it in GitHub Desktop.
// ...
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