Clientcide 2.0.2: Event Delegation Updated for MooTools 2.0 Compatibility
I’ve just made an update to the Clientcide libs. Aside from a few minor tweaks and fixes, the big change is that I’ve updated my Event.Delegation.js beta plugin.
MooTools 2.0 features built in event delegation (among many, many other enhancements) but the syntax is a little different than the previous version of my beta plugin. While my previous version had the syntax like this:
element.addEvent('click(a)', function(){...});
MooTools 2.0 currently has the syntax as:
element.addEvent('click:relay(a)', function(){...});
I’ve updated my version to use this new syntax which should make it a little safer to use. For starters, assuming the syntax doesn’t change in 2.0 (which it totally could), you won’t have to do anything when you upgrade. But the other benefit is that, if the syntax changes, it’ll be easier to find them. My previous version is basically impossible to search for in your code, which means that if you’ve been using it in your work and need to update the syntax, it’s going to be hard to find them all.
Warning!
To help with this migration I’ve added a little logic to the code so that if it sees you trying to add an event with the old syntax (‘click(a)’) it’ll post a console warning that the selector is no longer valid. This should make it possible for you to browse around your application(s) and see if there are any warnings.
Still Not Perfect
It’s also worth noting that my plugin still suffers from the same problems it had before. Namely, you can’t monitor the blur and focus events and some custom events might not work for you (I haven’t tested them all, but I suspect some won’t work).
Other than that, I’m going to upgrade this from “academic exercise” to “totally usable but might mean some work to upgrade later.”
Follow @clientcide on twitter to get notified of new posts.
To follow me personally on twitter, follow @anutron.

April 27th, 2009 at 12:22 pm
You can get focus and blur to work using Event Capturing. Not sure if 2.0 already has this worked out, but it’s working in YUI. Just watched Quirksmode talk about it in YUI Theater, look at -28:00.
April 27th, 2009 at 12:47 pm
Yes, I know how to do it. The problem is that 1.2* doesn’t allow you to use capturing. If I want to support it I’d have to basically duplicate addEvent and the garbage collector. I’m content to wait for 2.0, which does this for me.
April 27th, 2009 at 5:51 pm
@Aaron
So… will focus and blur delegation work with 2.0?
April 27th, 2009 at 8:17 pm
How exciting! I can’t wait to see the performance from the event delegation.