Alright, another question to pin on the experts. :D
I have an issue with "this" keyword in this case. The way I got around it before was to use a window property, but in this case I'm trying to keep everything within the context of the object.
So... Basically, this is referring to what I wanted it to refer to before (well, it worked in Mozilla, but not in IE, so I used the window workaround to fit both browsers).
What I want to do apparently is to mimic what IE (gasp) does with attachEvent in other browsers to make this. in a couple of my functions to refer to the object they're a part of, and not the element they were called by.
Problem lines (I think): 95, 96, 120, 219 (the entire function needs to be referenced), 449, 466 (the entire function needs to be referenced), 483, 491, 549, 603 (the entire function needs to be referenced), 623, 676 (the entire function needs to be referenced), 761, 770 (the entire function needs to be referenced), 791 (the entire function needs to be referenced).
Here are those specific lines (in order):
Full library: http://preview.moltx.name/chat_v2/chat.js
What I need is probably not with the function definitions to be changed, but rather how do I make this in those functions refer to the chat object no matter what?
I have an issue with "this" keyword in this case. The way I got around it before was to use a window property, but in this case I'm trying to keep everything within the context of the object.
So... Basically, this is referring to what I wanted it to refer to before (well, it worked in Mozilla, but not in IE, so I used the window workaround to fit both browsers).
What I want to do apparently is to mimic what IE (gasp) does with attachEvent in other browsers to make this. in a couple of my functions to refer to the object they're a part of, and not the element they were called by.
Problem lines (I think): 95, 96, 120, 219 (the entire function needs to be referenced), 449, 466 (the entire function needs to be referenced), 483, 491, 549, 603 (the entire function needs to be referenced), 623, 676 (the entire function needs to be referenced), 761, 770 (the entire function needs to be referenced), 791 (the entire function needs to be referenced).
Here are those specific lines (in order):
Code:
this.button.addEventListener ('click', this.submitMessage, (false));
this.message.addEventListener ('click', this.character, (false));
setTimeout (this.scanUsers, this.usersUpdateRate);
chat.prototype.client = function ()
setTimeout (this.retrieve, this.historyUpdateRate);
chat.prototype.retrieve = function ()
this.connection.addEventListener ('readystatechange', this.client, (false));
setTimeout (this.retrieve, this.historyUpdateRate);
this.connection.addEventListener ('readystatechange', this.client, (false));
chat.prototype.scanUsers = function ()
setTimeout (this.scanUsers, this.usersUpdateRate);
chat.prototype.bottom = function (starting)
setTimeout (this.bottom, this.scrollSpeed);
chat.prototype.character = function (e)
chat.prototype.submitMessage = function ()
What I need is probably not with the function definitions to be changed, but rather how do I make this in those functions refer to the chat object no matter what?
Comment