Thomas Fuchs
Hi, I'm Thomas Fuchs. I'm the author of the script.aculo.us user interface JavaScript library, a member of the Prototype core team and a Ruby on Rails core alumnus. You're using my work every day, even if you're not aware of it (sounds creepy, I know!). Need JS foo? Hire me.

event:Selectors for Prototype

March 21st, 2006 by Thomas Fuchs, Comments Off

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

It’s inspired by behaviour.js, but builds on all the latest Prototype goodness and adds some nice new features.

Here’s a snippet of what you can do (notice how nicely it works together with script.aculo.us!):


var Rules = {
  '#icons a:mouseover': function(element) {
     var app = element.id;
     new Effect.BlindDown(app + '-content',
       {queue: 'end', duration: 0.2});
   },

   '#icons a:mouseout': function(element) {
     var app = element.id;
     new Effect.BlindUp(app + '-content',
       {queue: 'end', duration: 0.2});
  }
}

Examples for multiple assignments and event passing:


'#feature, #otherstuff': function(element) {
  Sortable.create(element);
}

'.links a:click': function(element, event) {
  $('item').toggle();
  Event.stop(event);
}

Update: Here’s the official announcement from Justin – and shame on me for leaking :)

Post to Twitter Tweet This Post Post to Digg Digg This Post Post to Facebook Share on Facebook

Comments Off

JavaScript Rocks! Peformance ebook
Do you run a web site or web application? Do your users a favor, and grab our ebook on JavaScript performance. Profit from our knowledge gathered in over 15 years of working with the Web and JavaScript and make your sites ultra-fast and your users ultra-happy.

Comments are closed.