if i understand correctly, the real issue is if child requires other parameters. and anyway, a class creating other classes (other than perhaps mootools utilities) is a bad habit. imo, if the class is supplied via options, the supplier should already instantiate the class
On Fri, Nov 19, 2010 at 7:21 PM, Alex K <[email protected]> wrote: > I apologize for bringing up a topic that might have been discussed in the > past, but I wonder if anyone has a definite and clear solution to this > problem: > > > var A = new Class({ > Implements : Options, > > initialize : function(options) { > this.setOptions(options); > if (options && typeOf(options.child) == 'class') > this.child = new options.child(options); > } > }); > > var B = new Class({ > Implements : A, > }); > > // "Maximum call stack size exceeded" > var instance = new A({child : B}); > > > Also, due to some design considerations, implementing "initialize" in > every subclass is not an option. > > Thanks in advance. > -a > -- Arieh Glazer אריה גלזר 052-5348-561 5561
