Domini
2008-Apr-27 19:35 UTC
document.getElementsByName("form_elements_representing_arrray[]") shortcut with auto Element.extend()?
Is there any shortcut to
document.getElementsByName("form_elements_representing_arrray[]") with
auto Element.extend()?
I use
$A(document.getElementsByName("form_elements_representing_arrray[]")).map(Element.extend)
but that''s long! :)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
kangax
2008-Apr-27 20:08 UTC
Re: document.getElementsByName("form_elements_representing_arrray[]") shortcut with auto Element.extend()?
Of course there is:
$$(''name="form_elements_representing_arrray[]"'')
- kangax
On Apr 27, 3:35 pm, Domini
<Domini...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Is there any shortcut to
> document.getElementsByName("form_elements_representing_arrray[]")
with
> auto Element.extend()?
>
> I use
>
$A(document.getElementsByName("form_elements_representing_arrray[]")).map(Element.extend)
> but that''s long! :)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Domini
2008-Apr-27 20:28 UTC
Re: document.getElementsByName("form_elements_representing_arrray[]") shortcut with auto Element.extend()?
Wonderful. )
But... what am I doing wrong?
Event.observe(window,"load",select_all_initialize);
function select_all_initialize()
{
$("select_all").observe("click",select_all); //
$("select_all") is a
checkbox
}
function select_all()
{
// $$(''name="values[]"'') are checkboxes also.
$A(document.getElementsByName("values[]")).map(Element.extend).invoke("writeAttribute","checked",this.checked);
//
This works.
$$
(''name="values[]"'').invoke("writeAttribute","checked",this.checked);
//
This doesn''t.
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Andrew Dupont
2008-Apr-27 20:33 UTC
Re: document.getElementsByName("form_elements_representing_arrray[]") shortcut with auto Element.extend()?
kangax has led you astray! ;)
$$(''*[name="values[]"]'').invoke(''writeAttribute'',
''checked'',
this.checked);
Cheers,
Andrew
On Apr 27, 3:28 pm, Domini
<Domini...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Wonderful. )
>
> But... what am I doing wrong?
>
> Event.observe(window,"load",select_all_initialize);
> function select_all_initialize()
> {
> $("select_all").observe("click",select_all); //
$("select_all") is a
> checkbox}
>
> function select_all()
> {
> // $$(''name="values[]"'') are checkboxes
also.
>
>
$A(document.getElementsByName("values[]")).map(Element.extend).invoke("writ
eAttribute","checked",this.checked); //
> This works.
> $$
>
(''name="values[]"'').invoke("writeAttribute","checked",this.checked);
//
> This doesn''t.
>
> }
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Domini
2008-Apr-27 20:45 UTC
Re: document.getElementsByName("form_elements_representing_arrray[]") shortcut with auto Element.extend()?
Yes, this works. But after all perfomance has decreased significantly. On a small page including 30 checkboxes ~2 sec. for first call. Is there a workaround? Or is this a problem of using the framework? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Domini
2008-Apr-27 20:58 UTC
Re: document.getElementsByName("form_elements_representing_arrray[]") shortcut with auto Element.extend()?
Got it!
$$(''input[type="checkbox"][name="values[]"]'');
Thanks for the workaround with route_ids_new[], the code is much more
readable.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---