If you're interested, I've actually built a "bridge" library called GenevaJS that does exactly what you're looking for.
Keep in mind, it's not yet finished, but the core concept you're looking for, things like: $('collection').addClassName('classname'); Is there. Yes... thats a single $... GenevaJS modifies the $ to behave like $$ (without breaking anything...ever) http://genevajs.com Rick On Thu, Jul 30, 2009 at 2:43 PM, Ken Snyder <kendsny...@gmail.com> wrote: > Mike, > > Yes, that type of class is quite helpful. Here is a concise implementation > of your idea: http://gist.github.com/158849 > > It could be improved a lot. For example, you could alter > Element.addMethods() to also add methods to the NodeList object. > > This type of class is probably appropriate for a Scripteka submission, but > there may be other implementations already there. Feel free to use my code > however you like and submit it if you want. > > Best regards, > > Ken Snyder > > > On Mon, Jul 27, 2009 at 2:53 PM, Mike Rumble <mike.rum...@gmail.com>wrote: > >> >> 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 -~----------~----~----~----~------~----~------~--~---