I''m sure this has been covered before, but here goes... Anybody noticing some odd behavior with submitting forms through Ajax.Request? I thought at first it was a problem with Form.serialize, but was able to trace it back to line #975 (in prototype 1.5.1_rc2) which calls "toQueryParams" on the parameters that are passed into the new Ajax object if it is a string. This is the code (line #975 is the second line): if (typeof this.options.parameters == ''string'') this.options.parameters = this.options.parameters.toQueryParams(); A quick example could be seen by running the following in Firebug: "foo=bar&apple=&orange=".toQueryParams() The apple and orange parameters are left off due to being empty. In terms of forms and empty fields (which should trigger validation errors), this seems like a huge problem. Is my version of prototype just out-of-date or is there a fix for this in the foreseeable future? I know I can extend/override to fix this behavior. I''m not looking for a fix, just wondering if anybody else has seen this. -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 -~----------~----~----~----~------~----~------~--~---
Nobody has run into this? It is impossible to submit empty form fields through Ajax with this new behavior in Prototype. The best solution is to just switch forms to use normal POSTs, that''s lame. You can reproduce by doing my previous example, or even: new Ajax.Request(''/'', { parameters: ''x=&y=&foo=bar'' } ) Take a look at what was POSTed, it''s not what you''d expect. -justin On Apr 17, 5:31 pm, mr_justin <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m sure this has been covered before, but here goes... > > Anybody noticing some odd behavior with submitting forms through > Ajax.Request? I thought at first it was a problem with Form.serialize, > but was able to trace it back to line #975 (in prototype 1.5.1_rc2) > which calls "toQueryParams" on the parameters that are passed into the > new Ajax object if it is a string. This is the code (line #975 is the > second line): > > if (typeof this.options.parameters == ''string'') > this.options.parameters = this.options.parameters.toQueryParams(); > > A quick example could be seen by running the following in Firebug: > "foo=bar&apple=&orange=".toQueryParams() > > The apple and orange parameters are left off due to being empty. In > terms of forms and empty fields (which should trigger validation > errors), this seems like a huge problem. > > Is my version of prototype just out-of-date or is there a fix for this > in the foreseeable future? I know I can extend/override to fix this > behavior. I''m not looking for a fix, just wondering if anybody else > has seen this. > > -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 -~----------~----~----~----~------~----~------~--~---
mr_justin wrote:> Nobody has run into this? It is impossible to submit empty form fields > through Ajax with this new behavior in Prototype.Sorry no-one has responded yet. It''s been talked about quite a bit. http://groups.google.com/group/prototype-core/browse_thread/thread/711012b806b3ad36/75b3de9077ec6007#75b3de9077ec6007 http://groups.google.com/group/prototype-core/browse_thread/thread/83996a20fecd61c4/8775c0b24361ae60#8775c0b24361ae60 It has been fixed in SVN and is scheduled to be in 1.5.1> The best solution is > to just switch forms to use normal POSTs, that''s lame.You might try passing parameters as an object instead of a string so that toQueryParams() is not called. new Ajax.Request(''/'', { parameters: { x: '''', y: '''', foo: ''bar'' } } ) -- Michael Peters Developer Plus Three, LP --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for your response Michael. I guess I should have clarified that I''m using Rails built-in helpers like form_remote_tag and link_to_remote, which generate the JavaScript for us. Extending either JS or Rails seems like an adequate fix, for now. -justin On 4/18/07, Michael Peters <mpeters-aUYv5hkjw45l57MIdRCFDg@public.gmane.org> wrote:> > mr_justin wrote: > > Nobody has run into this? It is impossible to submit empty form fields > > through Ajax with this new behavior in Prototype. > > Sorry no-one has responded yet. It''s been talked about quite a bit. > > http://groups.google.com/group/prototype-core/browse_thread/thread/711012b806b3ad36/75b3de9077ec6007#75b3de9077ec6007 > http://groups.google.com/group/prototype-core/browse_thread/thread/83996a20fecd61c4/8775c0b24361ae60#8775c0b24361ae60 > > It has been fixed in SVN and is scheduled to be in 1.5.1 > > > The best solution is > > to just switch forms to use normal POSTs, that''s lame. > > You might try passing parameters as an object instead of a string so that > toQueryParams() is not called. > > new Ajax.Request(''/'', { parameters: { x: '''', y: '''', foo: ''bar'' } } ) > > -- > Michael Peters > Developer > Plus Three, LP > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Justin, This has been corrected in the svn trunk: $H("foo=bar&apple=&orange=".toQueryParams()).toQueryString() // => "foo=bar&apple=&orange=" Regards, Tobie --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Indeed it is, thanks Tobie! -justin On 4/18/07, tobie <tobie.langel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi Justin, > > This has been corrected in the svn trunk: > > $H("foo=bar&apple=&orange=".toQueryParams()).toQueryString() > // => "foo=bar&apple=&orange=" > > Regards, > > Tobie > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---