I''ve been using Ben Nolan''s behaviour.js script for a while to organize my javascript application to my html, but I''ve been watching as $$() develops as well. It''s now more complete wrt CSS syntax and has gotten some speed improvements recently too. In a new project I''m planning on using $$() instead of behaviour.js. I do have one question though. $$() doesn''t appear to work on partial documents (which is a problem with behaviour.js too) but Element.getElementsBySelector() does. I''d like to have this feature in my behaviour.js replacement so I was wondering a couple of things: + Why doesn''t $$() do this already? + Did Element.getElementsBySelector get the same recent improvements as $$()? Thanks -- Michael Peters Developer Plus Three, LP --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Michael, Element.getElementsBySelector is based on $$, so yes, it got the same improvements. Can''t answer the rest, sorry! Regards, Tobie On Mar 13, 10:35 am, Michael Peters <mpet...-aUYv5hkjw45l57MIdRCFDg@public.gmane.org> wrote:> I''ve been using Ben Nolan''s behaviour.js script for a while to organize my > javascript application to my html, but I''ve been watching as $$() develops as > well. It''s now more complete wrt CSS syntax and has gotten some speed > improvements recently too. In a new project I''m planning on using $$() instead > of behaviour.js. > > I do have one question though. $$() doesn''t appear to work on partial documents > (which is a problem with behaviour.js too) but Element.getElementsBySelector() > does. I''d like to have this feature in my behaviour.js replacement so I was > wondering a couple of things: > > + Why doesn''t $$() do this already? > + Did Element.getElementsBySelector get the same recent improvements as $$()? > > Thanks > -- > Michael Peters > Developer > Plus Three, LP--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
tobie wrote:> Hi Michael, > > Element.getElementsBySelector is based on $$, so yes, it got the same > improvements. > > Can''t answer the rest, sorry!That was my primary question anyway. I guess it doesn''t really matter if $$() doesn''t do all that getElementsBySelector() does since it''s just a shortcut. Thanks -- Michael Peters Developer Plus Three, LP --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It just might have to do with the fact that $$()''s scope is the whole document, while getElementsBySelector is scoped by an element. On Mar 13, 11:28 am, Michael Peters <mpet...-aUYv5hkjw45l57MIdRCFDg@public.gmane.org> wrote:> tobie wrote: > > Hi Michael, > > > Element.getElementsBySelector is based on $$, so yes, it got the same > > improvements. > > > Can''t answer the rest, sorry! > > That was my primary question anyway. I guess it doesn''t really matter if $$() > doesn''t do all that getElementsBySelector() does since it''s just a shortcut. > > Thanks > -- > Michael Peters > Developer > Plus Three, LP--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hey there,> That was my primary question anyway. I guess it doesn''t really matter if $$() > doesn''t do all that getElementsBySelector() does since it''s just a shortcut.Uh?! 1) $$ boils is: return Selector.findChildElements(document, $A(arguments)); 2) getElementsBySelector boils down to: return Selector.findChildElements(element, args); So the only difference is the initial scope, really. If you want to use $$ instead of the (verbose) $(''someID'').getElementsBySelector(...), just say $$(''#someID ...''). Won''t be slower, I promise you that. However, if you already have an element reference, turning over to $$ with something like $$(''#'' + elt.id + '' ...'') is essentially a useless roundtrip: you scope out to scope in again. -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve wrote:> Hey there, > >> That was my primary question anyway. I guess it doesn''t really matter if $$() >> doesn''t do all that getElementsBySelector() does since it''s just a shortcut. > > Uh?!I meant, I guess it doesn''t matter that $$() doesn''t take the extra element argument like getElementsBySelector() does since $$() is just a shortcut. Not that it doesn''t handle the same CSS rules. -- Michael Peters Developer Plus Three, LP --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---