Wednesday, March 22nd, 2006

event:Selectors for Prototype

According to this post on the website, Justin Palmer has released event:Selectors, a “method to cleanly use CSS pseudo selectors to assign DOM events to elements on the page.”

The functionality, bearing resemblance to the behaviour.js library, hooks into all of the latest Prototype functionality and adds a few tricks of its own. They provide a code example of how this new functionality can be used:


  1. var Rules = {
  2.   '#icons a:mouseover': function(element) {
  3.      var app =;
  4.      new Effect.BlindDown(app + '-content',
  5.        {queue: 'end', duration: 0.2});
  6.    },
  8.    '#icons a:mouseout': function(element) {
  9.      var app =;
  10.      new Effect.BlindUp(app + '-content',
  11.        {queue: 'end', duration: 0.2});
  12.   }
  13. }

Posted by Chris Cornutt at 7:59 am

4.4 rating from 70 votes


Comments feed TrackBack URI

Can someone explain how this is different from Behaviour?

Comment by Aibean — March 22, 2006

Note the section near the bottom:
“Whats the difference between event:Selectors and Behaviour?”

They give a few differences…

Comment by Chris Cornutt — March 22, 2006

Is this related to scriptaculous somehow? The “new Effect.Blah(…)” looks like what scriptaculous has.

Comment by falcon — March 22, 2006

Its not directly related to scriptaculous, but to prototype (and scriptaculous is based on prototype).

I have looked at this solution and I find it alot better then behaviour, atleast when if you already use prototype.. then this is preferable.

One great addition though would be support for attribute selectors (in prototype $$function, which is used by event selectors)

Comment by Alexander — March 22, 2006

Behaviour seems to appear first, and it is a really smart idea. This one is the further improvement of the same idea, but rules look simpler. Like it!

Comment by Michael Jouravlev — March 22, 2006

Sorry I am sticking with Prototype and Prototype Mods (no Jquery for me)

Comment by John — March 26, 2006

Sorry I am sticking with Prototype and Prototype Mods No Jquery for me

Comment by John — March 26, 2006

Leave a comment

You must be logged in to post a comment.