Hey, I know it''s been discussed before but could someone provide some
insight into why $F doesn''t support radio buttons and serialize does?
[techncially i understand why but why has the code not been upgraded]
I know that a radio button is grouped via its name attribute, rather than
having a unique id ($F() really should refer to the Id of the element for
consistency)
Why not use the $$ function to get radio buttons (internally)
It seems the only reason that $F doesn''t return the checked radio
button in
the group is that it''s targeted to work on a single element (and
rightly so,
I guess)... so Form.Element.Serializers[Input](Element) gets passed a
reference to a name instead of an id...
Serialize will work because the Serializer function for Input -> radio
returns null if not checked and the serialize method is called once for each
element in the form, so if one of the radio buttons is checked, then it will
return that one. (works for tickboxes too in this respect). null values
never reach the output due to an if.
You could expand on this a little...
I''ve made a change to $F locally, but I really don''t think it
cuts the
mustard, it''s certainly not as clean as the rest of the prototype code
i''ve
read...
Okay, here we go
*//var $F = Form.Element.Methods.getValue;*
*function $F(Element)
{
if (typeof Element == ''string'') Element = $(Element);
if(Element.type && Element.type == ''radio'' &&
Element.name) { var v
Form.serializeElements($$("Input[type=radio][name=''" +
Element.name.replace("''","''''")
+ "'']"),true); return $H(v).pluck(''value'');
}
return Form.Element.Methods.getValue(Element);
}*
I''ve tried to make it only drop into the new code to save cycles, but
ended
up with 5 ifs and a $() call to do so
Completely understand if this is wasted effort, it was more a test of my own
understanding than anything
I''ve checked trac, i didn''t see anything similar.
Gareth
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---