| Page 1 of 1 | [ 3 posts ] |
|
Hi everybody!
I've just started to learn YUI3, and I think I'll have a lot of questions about it. I'm trying to create hierarchy of widgets like: Exchange < Resources < Widget. Because Exchange widget is slightly different than Resources widget, I need to override e.g. renderUI method to add some additional stuff there. The question is: how can I call renderUI method from base (Resources) class? After a lot of different approaches I've found the bind method working: Code: renderUI: function() { Y.bind(Resources.superclass.renderUI, this)(); } Is there any easier way to do it? Another qustion: can I create widgets inside of other widgets? I know it's possible, but does it make any sense? Maybe there's a better way to do it? I'm trying to make a game based on The Settlers of Catan board game. The code is available on Github: http://github.com/qoobaa/pioneers/tree/yui. ANY help is appreciated, I'd be perfect to hear a criticism or some hints |
|
If I'm following you correctly (Exchange extends Resource extends Widget), you can just do this:
Code: Exchange.prototype.renderUI = function() { // Call Resource's renderUI from Exchange return Exchange.superclass.renderUI.apply(this, arguments); } or, Resource.prototype.renderUI = function() { // Call Widget's renderUI from Resource return Resource.superclass.renderUI.apply(this, arguments); } Yes, you can nest Widgets, however we don't have the parent/child relationship formalized yet. Look for that to take shape in the 3.1 release. |
|
sdesai wrote: Code: Exchange.prototype.renderUI = function() { // Call Resource's renderUI from Exchange return Exchange.superclass.renderUI.apply(this, arguments); } I want to mention for your own troubleshooting that .apply(..) gives me in my class hierarchies a silent die on calling my superclass constructors (and methods). I only get this working with Code: superclass.constructor.call(this, args); Regards |
| 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