kishore.sayee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Apr-28 18:42 UTC
How to pass variable to $$()?
Hi all,
I want the $$() method to take the selector as an variable. See
below, I am trying to pass the class name as javascript variable so I
can write a generic function in my application but $$() returns
nothing for the following line
var currentHightLightGroup ="amountsFields";//This one comes as a
function parameter
$$(''span[class=\''''+currentHightLightGroup+''\'']'')
-> returns nothing.
Any help is much appericated.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
why not use class syntax? "span.amountsFields" On 4/28/08, kishore.sayee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <kishore.sayee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi all, > > I want the $$() method to take the selector as an variable. See > below, I am trying to pass the class name as javascript variable so I > can write a generic function in my application but $$() returns > nothing for the following line > > var currentHightLightGroup ="amountsFields";//This one comes as a > function parameter > $$(''span[class=\''''+currentHightLightGroup+''\'']'') > -> returns nothing. > > Any help is much appericated. > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
$$(''span.'' + currentHighlightGroup);
// or
$$(''span'').findAll(function(el){
return el.hasClassName(currentHighlightGroup)
});
// the latter one will actually be much slower...
- kangax
On Apr 28, 2:42 pm,
"kishore.sa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
<kishore.sa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi all,
>
> I want the $$() method to take the selector as an variable. See
> below, I am trying to pass the class name as javascript variable so I
> can write a generic function in my application but $$() returns
> nothing for the following line
>
> var currentHightLightGroup ="amountsFields";//This one comes as a
> function parameter
>
$$(''span[class=\''''+currentHightLightGroup+''\'']'')
> -> returns nothing.
>
> Any help is much appericated.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
kishore.sayee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Apr-28 21:42 UTC
Re: How to pass variable to $$()?
Thanks much, It worked. On Apr 28, 3:39 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> $$(''span.'' + currentHighlightGroup); > > // or > > $$(''span'').findAll(function(el){ > return el.hasClassName(currentHighlightGroup) > > }); > > // the latter one will actually be much slower... > > - kangax > > On Apr 28, 2:42 pm, "kishore.sa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" > > <kishore.sa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi all, > > > I want the $$() method to take the selector as an variable. See > > below, I am trying to pass the class name as javascript variable so I > > can write a generic function in my application but $$() returns > > nothing for the following line > > > var currentHightLightGroup ="amountsFields";//This one comes as a > > function parameter > > $$(''span[class=\''''+currentHightLightGroup+''\'']'') > > -> returns nothing. > > > Any help is much appericated.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---