[thelist] 'classes' in javascript
Matt Warden
mwarden at gmail.com
Tue Jun 14 23:20:01 CDT 2005
thelist,
Trying to work with JS 'classes' and I'm having a little bit of
trouble. See below:
function RemoteConnection()
{
this.aRequests = new Array();
this.aRequests[0] = null;
this.request = function(url, method, requestxml)
{
alert(this);
// ...
};
this.handle = function()
{
alert(this);
// ...
}; // end method handle
// ...
} // end class RemoteConnection
The first time I RemoteConnection().request(...) is called first, and
the alert reports that 'this' is an object. This is what I expect. The
second method fired is .handle(); this is actually being fired by an
event trigger that is set up in request():
req.onreadystatechange = this.handle;
The second alert (in handle()) alerts the contents of the function
(i.e., literally the function's code). I seemingly do not have access
to the properties of teh containing 'class' (RemoteConnection).
I want to be able to refer to the current RemoteConnection instance.
How can I do this?
Thanks,
--
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com
This email proudly and graciously contributes to entropy.
More information about the thelist
mailing list