Possible Duplicate:
In Javascript, why is the “this” operator inconsistent?
I have the following class:
function Chat(some, nick, url) {
this.socket = null;
this.Nickname = nick;
this.Url = url;
this.Connect = function () {
socket = io.connect(this.Url);
socket.on('connect', function (data) {
var p = this.Nickname; //this.Nickname is undefined why?
// how can I acess to the Nickname variable or function?
}
};
}
How can I acces the instance variable or function from the connect callback function?