See the example below:
I guess Prototype doesn''t like that the form
"driving_directions" has
two inputs with the same name, which is valid HTML.
The second form is correctly serialized.
<html>
<head>
<script type="text/javascript"
src="/w2gi/javascript/prototype.js"></script>
<script>
function serialize() {
var form = $(''driving_directions'');
var str = Form.serialize(form);
console.log(str);
alert(str);
var form2 = $(''driving_directions2'');
var str2 = Form.serialize(form2);
console.log(str2);
alert(str2);
}
</script>
</head>
<body onload="serialize();">
<form id="driving_directions">
<input type="text" size="28"
name="addressline"
value="Chicago, IL 60606"/>
<input type="text" size="28"
name="addressline"
value="Wheeling, IL 60090"/>
</form>
<form id="driving_directions2">
<input type="text" size="28"
name="addressline"
value="Chicago, IL 60606"/>
<input type="text" size="28"
name="addressline2"
value="Wheeling, IL 60090"/>
</form>
</body>
</html>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
I believe it''s caused by this Patch: http://dev.rubyonrails.org/ticket/6366 [Ajax mega-patch] Problem mentioned here: http://dev.rubyonrails.org/ticket/6645 [Closed, wontfix] Ajax.Request was set to convert passed strings to a hash, then back to a string. Around the same time, the behavior of Form.Serialize was changed to return a hash as well. TAG On Jan 26, 2007, at 2:18 PM, Les wrote:> > See the example below: > > I guess Prototype doesn''t like that the form "driving_directions" has > two inputs with the same name, which is valid HTML. > > The second form is correctly serialized. > > <html> > <head> > <script type="text/javascript" > src="/w2gi/javascript/prototype.js"></script> > <script> > function serialize() { > var form = $(''driving_directions''); > var str = Form.serialize(form); > console.log(str); > alert(str); > > var form2 = $(''driving_directions2''); > var str2 = Form.serialize(form2); > console.log(str2); > alert(str2); > } > </script> > </head> > > <body onload="serialize();"> > <form id="driving_directions"> > <input type="text" size="28" name="addressline" > value="Chicago, IL 60606"/> > <input type="text" size="28" name="addressline" > value="Wheeling, IL 60090"/> > </form> > <form id="driving_directions2"> > <input type="text" size="28" name="addressline" > value="Chicago, IL 60606"/> > <input type="text" size="28" name="addressline2" > value="Wheeling, IL 60090"/> > </form> > </body> > </html> > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Jan 27, 7:18 am, "Les" <les.szkla...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> See the example below: > > I guess Prototype doesn''t like that the form "driving_directions" has > two inputs with the same name, which is valid HTML. > > The second form is correctly serialized.form.serialize() doesn''t work at all in Safari. Attempting the example at: <URL: http://prototypejs.org/api/form/serialize > gives: Value undefined (result of expression Form.Element.Serializers[method]) is not object. http://prototypejs.org/javascripts/prototype.js Line: 1872 Which is: var parameter = Form.Element.Serializers[method](element); -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Prototype team, hi! Would it be also possible to add to Prototype the ability to de- serialize form? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Fixed in SVN, see http://dev.rubyonrails.org/changeset/6048 best, thomas Am 27.01.2007 um 12:00 schrieb RobG:> > > > On Jan 27, 7:18 am, "Les" <les.szkla...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> See the example below: >> >> I guess Prototype doesn''t like that the form "driving_directions" has >> two inputs with the same name, which is valid HTML. >> >> The second form is correctly serialized. > > form.serialize() doesn''t work at all in Safari. Attempting the > example > at: > > <URL: http://prototypejs.org/api/form/serialize > > > gives: > > Value undefined (result of expression Form.Element.Serializers > [method]) > is not object. > http://prototypejs.org/javascripts/prototype.js Line: 1872 > > Which is: > > var parameter = Form.Element.Serializers[method](element); > > > -- > Rob > > > >-- Thomas Fuchs wollzelle http://www.wollzelle.com questentier on AIM madrobby on irc.freenode.net http://www.fluxiom.com :: online digital asset management http://script.aculo.us :: Web 2.0 JavaScript http://mir.aculo.us :: Where no web developer has gone before --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Here''s a simple workaround:
/**
* @param {HTMLElement} form
* @return {String} serialized form
*/
serializeForm: function(form) {
return
$(form).getInputs(''text'').invoke(''serialize'').join(''&'');
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---