[jQuery] Re: Javascript: OOP help, accessing parent objects

2007-06-26 Thread Christof Donat
Hi, Thanks, that's really great, I'll have to really play around with that when I've got the time to really get to grips with it. Can you do multiple inheritence with that trick? That is not a trick, but a usuall JavaScript idiom. You can simulate multiple inheritance as well, but then you

[jQuery] Re: Javascript: OOP help, accessing parent objects

2007-06-25 Thread Christof Donat
Hi, function Contained () { var self=this; self.var1=1; self.var2=2; self.method1=function () { }; } function Container () { var self=this; self.varA = 'a'; self.varB = 'b'; self.containedObj = new Contained; } var foo = new Container;

[jQuery] Re: Javascript: OOP help, accessing parent objects

2007-06-25 Thread Christof Donat
Hi, C++ ... (new Container()).containedObj.method1(); //How could method1 ever access varA? OOps, this shopuld of course read (new Container())-containedObj.method1(); Christof

[jQuery] Re: Javascript: OOP help, accessing parent objects

2007-06-25 Thread Gordon
Okay, thanks for the help. I was just trying to figure out how to do inheritence in javascript and instead embedded objects inside other objects. :) One solution I found was something like this: function Contained () { var self=this; self.var1=1; self.var2=2;

[jQuery] Re: Javascript: OOP help, accessing parent objects

2007-06-25 Thread Christof Donat
Hi, Okay, thanks for the help. I was just trying to figure out how to do inheritence in javascript and instead embedded objects inside other objects. :) Ah, what you are looking for is this: function super() { /*...*/ }; super.prototype = { varA: 'a', varB: 'b' } function

[jQuery] Re: Javascript: OOP help, accessing parent objects

2007-06-25 Thread RobG
On Jun 25, 6:42 pm, Gordon [EMAIL PROTECTED] wrote: I am tryign to make more use of OOP techniques in JavaScript, but most of the OOP I have done up to now has been in class-based languages, and I'm struggling a little with the prototype based approach used in javascript. I know this isn't

[jQuery] Re: Javascript: OOP help, accessing parent objects

2007-06-25 Thread Kenneth
On 6/25/07, Christof Donat [EMAIL PROTECTED] wrote: Hi, C++ ... (new Container()).containedObj.method1(); //How could method1 ever access varA? OOps, this shopuld of course read (new Container())-containedObj.method1(); Christof I don't post much, but I must say that's