| Page 1 of 1 | [ 3 posts ] |
|
Is it possible to have constructors when using Y.Base.create?
This is a component I am writing: Code: YUI.add('mycomponent', function (Y) { Y.namespace('myapp'); var mycomponent; mycomponent = Y.Base.create('mycomponent', Y.Base, [], { mycomponent: function(config){ //This doesn't seem to be used as the constructor Y.log(config); }, add: function () { Y.log('hi'); }, }, {}); Y.namespace('myapp').mycomponent = mycomponent; }, '1.0.0', { requires: ['node' ,'base'] }); I then use it like this: Code: var comp= new Y.myapp.mycomponent(Y.one('#test')); //Does not work How can I set up my component so that it has a constructor that can be passed values during instantiation? |
|
You use the initializer method to do what a constructor would normally do. It receives the same arguments the constructor would receive and it doesn't need to chain to the superclass constructor since Base takes care of that.
|
|
Thank you
|
| Page 1 of 1 | [ 3 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group