Friday, April 13, 2007

Prototype.js, onComplete and anonymous functions

Prototype.js, onComplete and anonymous functions

Embarrassing post showing how far behind I've allowed myself to get in my JS knowledge…

I was looking for a way to call multiple functions after an Ajax.Request, and this does the trick. This should also solve the question I had about how to pass arguments to an event that you're attaching using current versions of addEvent(). Also, reading the comments I find out how little I really know about prototype, having missed the whole event observer feature. The prototype version of our clunky old addOnload("attachBehaviors();"); function call is Events.observe(window,’load’,attachBehaviors);, more flexible and presumably more robust, I'll have to research whether it has the purported memory leaking problems of the PPK contest winner.

No comments: