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:

$$('.panel').addClassName('red').addClassName('blue');

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',
'blue');

At the same time I noticed the NodeList present in the BBC's new Glow
library (see here: 
http://www.bbc.co.uk/glow/docs/1.5/api/glow.dom.nodelist.shtml
), 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
lame....

var NodeList = Class.create(Enumerable, {
  initialize : function(elements){
    this.elements = elements;
  },
  _each : function(iterator){
    this.elements.each(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.

Thanks,
Mike.


--~--~---------~--~----~------------~-------~--~----~
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 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to