I have an object, a, defined in a js file, with functions b, c and d
thus:
function a()
{
function b() { ... this.sth.dosth ... }
function c() { ... this.sth.dosthe lse ... }
function d() { ... c() ... }
this.b = b;
this.d = d;
}
and b and d are exposed as methods as shown.
When called externally as e.g. "x=new a(); x.b();" the function b ca
find 'this.sth' as expected, and Venkman tells me that the value o
this is the a object. However, when c (which is defined a few line
after b, definitely still within a) is called from d e.g. by the we
page going "x=new a(); x.d();", I find that the value of the 'this
inside c is the window object, just as if c were global code.
I am getting around it by coding, inside d, "c.apply( this )", but tha
seems to be an ugly hack. Have I fallen foul of some kind of Javascrip
gotcha? Is it a bug?
Cheers,
Loldemort
--
Loldemor
-----------------------------------------------------------------------
Loldemort's Profile: http://www.highdots.com/forums/member.php?userid=1
View this thread: http://www.highdots.com/forums/showthread.php?t=7097
Comment