that = this;
and go on about your merry way, using "that.whatever" in your callback functions. You finish your widget and start working on higher-level code, which happens to create a few of your widgets scattered around a page. But for some weird reason, your widget no longer updates when you click on it.
Puzzled, you try to debug the situation... yes, the events are happening. Yes, the values are getting set to the correct values... but they don't update on the page. You spend a bit of time sulking and playing with the silly things... then you notice... there is *one* widget that updates. What's more, it updates whenever you change *any* instance of your widget.
You shake your head, cry a tear (particularly if you remember just a few weeks earlier defending this particular wart as "dumb, but not enough to throw out the whole language") and alter your declaration to:
var that = this;
Imagining that next time you will remember this immediately, but realizing deep in your heart that something this silly just isn't going to stick in your memory, the beauty-loving part is going to have to block it out if you are to retain your sanity.
Pingbacks are closed.