J. Gregory Wright
2008-Mar-05 23:44 UTC
Equivalent of $() for HTMLDocument#getElementsByName()?
As in, is there one in the core Prototype implementation? Since $ (name) should map to a single element in the document (because each ''id'' attribute value should be unique since it is used by CSS), shouldn''t you be able to have the same kind of access for retrieving multiple document elements with the same name, such as: function $N(element) { var elements = new Array(); if (arguments.length == 1) { elements = document.getElementsByName(element).collect(function(e) { return Element.extend(e); }); } return elements; } such that: var removers = $N(''removeIcons''); would return an array of extended elements whose HTML name attribute is ''removeIcons''. Inquiring minds... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
What''s wrong with $$ helper? $$(''[name=removeIcons]''); // document wide //or someForm.select(''[name=someName]''); // down from some element http://www.prototypejs.org/api/utility/dollar-dollar - kangax On Mar 5, 6:44 pm, "J. Gregory Wright" <daecab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> As in, is there one in the core Prototype implementation? Since $ > (name) should map to a single element in the document (because each > ''id'' attribute value should be unique since it is used by CSS), > shouldn''t you be able to have the same kind of access for retrieving > multiple document elements with the same name, such as: > > function $N(element) { > var elements = new Array(); > if (arguments.length == 1) { > elements = document.getElementsByName(element).collect(function(e) > { > return Element.extend(e); > }); > } > return elements; > > } > > such that: > > var removers = $N(''removeIcons''); > > would return an array of extended elements whose HTML name attribute > is ''removeIcons''. > > Inquiring minds...On Mar 5, 6:44 pm, "J. Gregory Wright" <daecab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> As in, is there one in the core Prototype implementation? Since $ > (name) should map to a single element in the document (because each > ''id'' attribute value should be unique since it is used by CSS), > shouldn''t you be able to have the same kind of access for retrieving > multiple document elements with the same name, such as: > > function $N(element) { > var elements = new Array(); > if (arguments.length == 1) { > elements = document.getElementsByName(element).collect(function(e) > { > return Element.extend(e); > }); > } > return elements; > > } > > such that: > > var removers = $N(''removeIcons''); > > would return an array of extended elements whose HTML name attribute > is ''removeIcons''. > > Inquiring minds...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
J. Gregory Wright
2008-Mar-06 15:55 UTC
Re: Equivalent of $() for HTMLDocument#getElementsByName()?
I guess that in reading the summary pages for the Utility Functions I got the impression that this method was reliant on CSS classes assigned to elements. *sheepish grin* Looking at the detailed description of the $$() method now, this probably will do what I want... time to get to work and experiment. Thanks! G On Mar 5, 7:21 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> What''s wrong with $$ helper? > > $$(''[name=removeIcons]''); // document wide > > //or > > someForm.select(''[name=someName]''); // down from some element > > http://www.prototypejs.org/api/utility/dollar-dollar > > - kangax > > On Mar 5, 6:44 pm, "J. Gregory Wright" <daecab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > As in, is there one in the core Prototype implementation? Since $ > > (name) should map to a single element in the document (because each > > ''id'' attribute value should be unique since it is used by CSS), > > shouldn''t you be able to have the same kind of access for retrieving > > multiple document elements with the same name, such as: > > > function $N(element) { > > var elements = new Array(); > > if (arguments.length == 1) { > > elements = document.getElementsByName(element).collect(function(e) > > { > > return Element.extend(e); > > }); > > } > > return elements; > > > } > > > such that: > > > var removers = $N(''removeIcons''); > > > would return an array of extended elements whose HTML name attribute > > is ''removeIcons''. > > > Inquiring minds... > > On Mar 5, 6:44 pm, "J. Gregory Wright" <daecab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > As in, is there one in the core Prototype implementation? Since $ > > (name) should map to a single element in the document (because each > > ''id'' attribute value should be unique since it is used by CSS), > > shouldn''t you be able to have the same kind of access for retrieving > > multiple document elements with the same name, such as: > > > function $N(element) { > > var elements = new Array(); > > if (arguments.length == 1) { > > elements = document.getElementsByName(element).collect(function(e) > > { > > return Element.extend(e); > > }); > > } > > return elements; > > > } > > > such that: > > > var removers = $N(''removeIcons''); > > > would return an array of extended elements whose HTML name attribute > > is ''removeIcons''. > > > Inquiring minds...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---