Erin Brewer wrote: > Cool, that works nicely. > > I've never actually come across the term 'closure' before in JS.
They appear in almost every dynamic language that supports lexical scoping (that I know of). Wikipedia has a nice description: Closure lexical variables differ from global variables in that they do not occupy the global variable namespace. They differ from object oriented object variables in that they are bound to functions, not objects. > Did a > quick search and read a couple things (still don't quite understand > exactly how that works to get the response reference?), but from my > reading, should i do anything after the clousre to avoid memory leaks? > This same function flow may be invoked multiple times per page depending > on the nature of the event (event1 does ajax stuff, response triggers > event2, etc.) You shouldn't have to worry about memory leaks (famous last words of JS programmers). That doesn't mean you won't and I've heard that IE doesn't handle all cases nicely, but I'm not sure about the specifics. Calling the function that returns the anonymous function multiple times shouldn't be a problem. Each function will have it's own lexical pad. Here's a little write up of the IE memory leak problem. The key is to avoid circular-references. http://jibbering.com/faq/faq_notes/closures.html#clMem -- Michael Peters Developer Plus Three, LP _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs