A developer that's recently joined my team is new to Prototype and is
finding himself trying to do things in a jQuery-ish way, for example:


I explained the differences between the Prototype and JQuery ways of
doing things, and demonstrated that the same result could be achieved
using Prototype with not a great deal more code:

$$('.panel').invoke('addClassName', 'red').invoke('addClassName',

At the same time I noticed the NodeList present in the BBC's new Glow
library (see here: 
), and wondered whether Prototype could benefit of a similar module to
allow the element methods to be invoked on a collection of DOM nodes
(the return of $$) and chained together jQuery-style.

A real basic implementation could look something like this, only less

var NodeList = Class.create(Enumerable, {
  initialize : function(elements){
    this.elements = elements;
  _each : function(iterator){
  item : function(i){
    return this.elements[i];
  addClassName : function(className){
    this.elements.invoke('addClassName', className);
    return this;
  // More methods here....

I don't think Prototype needs to make itself like jQuery, and I'm not
looking to start that debate here. I am however interested to hear if
anyone thinks there is any value in this approach, or indeed if not.

Personally I think it would do well to make Prototype more accessible
to newcomers.


You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to