|
|
Prototype And The This Keyword
|
01/16/2006, By Ryan Campbell
|
My personal love for Prototype.js is evident, and that love has grown further as I have become familiar with object oriented programming using the framework. However, my appreciation has come at the expense of a few growing pains, one of which is maintaining the this keyword when dealing with event handlers.
Normally in JavaScript, when you add an event handler such as onclick to an element, the triggered function can use the this keyword to refer to the element. Likewise, a class uses the this keyword to reference its member variables and methods. So, what happens when you attach an event to an element from within a class? Which object receives the attention of this this keyword?
Read more...
|
Rate this Ajax Articles
Rating: 0.0 out of votes cast
| |
|
|
|
|
|
|
|
|
|
|
|
|