Hi all,
I have a dynamic list of divs I want to add a class to:
$(''dynamic'').invoke(''addClassName'',
''border'')
The list can also only contain 1 div resulting in a unknown function
addClassName . Is this caused by the fact that there is only 1 div? Is
there a way around this?
thanks
Stijn
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Is there a way you could change the identifier to a classname?
$$(''div.myClass'') always returns an array, even if
it''s an array of one.
Walter
On Mar 7, 2008, at 11:42 AM, Tarscher wrote:
>
> Hi all,
>
> I have a dynamic list of divs I want to add a class to:
> $(''dynamic'').invoke(''addClassName'',
''border'')
>
> The list can also only contain 1 div resulting in a unknown function
> addClassName . Is this caused by the fact that there is only 1 div? Is
> there a way around this?
>
> thanks
> Stijn
> >
--~--~---------~--~----~------------~-------~--~----~
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 Stijn,
The $() utility function returns a single element, not an enumerable
array. $$(''dynamic'') returns elements with tag name
''dynamic''. I''m
guessing there won''t be any. $$(''#dynamic'') would
return an array of
your element. But, unless you have a good reason for needing an
array, $() is more appropriate.
Try:
$(''dynamic'').addClassName(''border'');
instead.
You should check out the API docs for instructions on how to use css
selectors:
http://www.prototypejs.org/api/utility/dollar-dollar
Regards,
Knox
On Mar 7, 9:42 am, Tarscher
<tarsc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi all,
>
> I have a dynamic list of divs I want to add a class to:
> $(''dynamic'').invoke(''addClassName'',
''border'')
>
> The list can also only contain 1 div resulting in a unknown function
> addClassName . Is this caused by the fact that there is only 1 div? Is
> there a way around this?
>
> thanks
> Stijn
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
On 7.3.2008, at 18.51, Walter Lee Davis <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> > Is there a way you could change the identifier to a classname? > > $$(''div.myClass'') always returns an array, even if it''s an array of > one. >$$(''#dynamic div'') does the same without the need to assign classes to the individual list elements. The rule of thumb is that $ returns a single element and $$ an array of elements. invoke is an array method. //jarkko> Walter > > On Mar 7, 2008, at 11:42 AM, Tarscher wrote: > >> >> Hi all, >> >> I have a dynamic list of divs I want to add a class to: >> $(''dynamic'').invoke(''addClassName'', ''border'') >> >> The list can also only contain 1 div resulting in a unknown function >> addClassName . Is this caused by the fact that there is only 1 div? >> Is >> there a way around this? >> >> thanks >> Stijn >>> > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---