I use elm to stand for element, and evt to stand for event. It's just a habit I have, to keep clear in my head what I am dealing with when I use an observer or an iterator.
If I am iterating over a collection of elements with each, I will usually write this: $$('.foo').each(function(elm){ /* do something to elm here */ }); Using elm here reminds me that I am dealing with an element, rather than an event, and that I will have direct access to the element. Using the same collection and observing the click on it, I would write this: $$('.foo').invoke('observe', 'click', function(evt){ // inside here, evt is the click event evt.stop(); // and 'this' is the element that received the click: one of the .foo elements this.highlight(); }); I prefer unobtrusive observers for several reasons. First, they remove the masses of repeating inline code from the HTML, where all it does is bloat the page without adding any value. Any time you find yourself writing the same thing more than once, that's an opportunity for improvement. Second, if your observer is all in one place, you can make sweeping changes without having to go back and rewrite every invocation of the method. Imagine if you changed your function definition to need two variables passed to it rather than one. With your method, that means touching every row of your interface, while with mine, you just rewrite it in one place. Walter On Oct 28, 2012, at 5:51 PM, donnek wrote: > On Sunday, 28 October 2012 20:32:34 UTC, Walter Lee Davis wrote: > Okay, that means that 'this' inside the Ajax.Updater is not set to what you > think it is. Try this: > <snip> > Much cleaner and fewer global variables are massacred. > > Hey, thanks! Both of those work. But I don't understand what "elm" (not the > tree, I assume!) and "evt" are/do. And why is the second cleaner (because I > find the first easier to understand). Thanks again for taking the time on > this. > > -- > You received this message because you are subscribed to the Google Groups > "Prototype & script.aculo.us" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/prototype-scriptaculous/-/eGR_Yuma92gJ. > To post to this group, send email to prototype-scriptaculous@googlegroups.com. > To unsubscribe from this group, send email to > prototype-scriptaculous+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.