Wednesday, March 22nd, 2006
event:Selectors for Prototype
According to this post on the mir.aculou.us 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:
-
-
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});
-
}
-
}
-












Can someone explain how this is different from Behaviour?
Note the section near the bottom:
“Whats the difference between event:Selectors and Behaviour?”
They give a few differences…
Is this related to scriptaculous somehow? The “new Effect.Blah(…)” looks like what scriptaculous has.
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)
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!
Jquery is better.
And I give you a treebar demo using juery.
TreeBar with jquery
Sorry I am sticking with Prototype and Prototype Mods (no Jquery for me)
Sorry I am sticking with Prototype and Prototype Mods No Jquery for me