Hi everyone, I''m using the serialize function to grab data from a form. Later on, I want to reverse this from the object and fill the form with the object data. I''m surprised there isn''t a deserialize or unserialize function in prototype -- anyone know why this isn''t here? How hard would it be to get something like this this into prototype? This is the code that I''m using (use at your own risk). function deserialize(formelement, objectdata) { keys = Object.keys(objectdata); inputs = $(formelement).getElements(); keys.each(function(key){ inputs.each(function(input) { if (input.name == key) { input.value = objectdata[key]; if (input.type == ''checkbox'') input.checked=objectdata[key]; } }); }); } Cheer, Justin --~--~---------~--~----~------------~-------~--~----~ 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 Justin, irrelative a écrit :> I''m surprised there isn''t a deserialize or unserialize function in > prototype -- anyone know why this isn''t here? How hard would it be to > get something like this this into prototype? This is the code that > I''m using (use at your own risk).Well, Prototype trunk features Form.Element.setValue, based on the new two-way F.E.Serializers. It''s not a perfect fit for deserialization yet, as it''s ID-oriented, not name-oriented, but it should help. -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: 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 -~----------~----~----~----~------~----~------~--~---