I have a form with several text_fields that is submitted with a standard "submit" button. With one of the text_fields, however, I''d like to have a "Test This" link next to it that will submit the text field entry and perform a simple test at the server. The server will then respond with some RJS to indicate pass/fail status. I can use "observe_field" to do this automatically on the field data, but I''d rather have a separate link to do this. Since this is part of a bigger form, I don''t think I can use another form_remote nested within. Is there a handy way to create such a thing? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jake Janovetz wrote:> I have a form with several text_fields that is submitted with a standard > "submit" button. > > With one of the text_fields, however, I''d like to have a "Test This" > link next to it that will submit the text field entry and perform a > simple test at the server. The server will then respond with some RJS > to indicate pass/fail status. > > I can use "observe_field" to do this automatically on the field data, > but I''d rather have a separate link to do this. > > Since this is part of a bigger form, I don''t think I can use another > form_remote nested within.That might be the notorious ''with FAQ'', which I myself have asked. Send the link_to_remote using :with => ''Form.serialize("my_form")'', IIRC. That converts the form''s current values into GET parameters. -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 15-Feb-07, at 1:18 PM, Phlip wrote:> > Jake Janovetz wrote: > >> I have a form with several text_fields that is submitted with a >> standard >> "submit" button. >> >> With one of the text_fields, however, I''d like to have a "Test This" >> link next to it that will submit the text field entry and perform a >> simple test at the server. The server will then respond with some >> RJS >> to indicate pass/fail status. >> >> I can use "observe_field" to do this automatically on the field data, >> but I''d rather have a separate link to do this. >> >> Since this is part of a bigger form, I don''t think I can use another >> form_remote nested within. > > That might be the notorious ''with FAQ'', which I myself have asked. > > Send the link_to_remote using :with => ''Form.serialize("my_form")'', > IIRC. > > That converts the form''s current values into GET parameters.or if you don''t want to sent the entire serialized form, you can use the following js method: function serialize_form_elements(form_elements_array) { var queryComponents = new Array(); for (var i = 0; i < form_elements_array.length; i++) { var queryComponent = Form.Element.serialize(form_elements_array [i]); if (queryComponent) queryComponents.push(queryComponent); } return(queryComponents.join(''&'')); } usage: get_query_string = serialize_form_elements([$(''form_element_1''), $ (''form_element_2'')); #you can probably just pass an array of element id''s and then plug that into like_to_remote with '':with'' as Phillip said. note: relies upon prototype''s Form.Element.serialize smarts. Cheers, Jodi General Partner The nNovation Group inc. www.nnovation.ca/blog --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks, Jodi, Philip-- I was having some trouble with some code I found. I''m using this: :with => "''bucket=''+$(''crummy'').value" and it seems to work just peachy! Cheers, Jake -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 15-Feb-07, at 1:32 PM, Jake Janovetz wrote:> > Thanks, Jodi, Philip-- > > I was having some trouble with some code I found. I''m using this: > > :with => "''bucket=''+$(''crummy'').value" > > and it seems to work just peachy!that''ll work just find until you try that trick with checkboxes, radiobuttons, selects. That''s when you want to serialize Cheers, Jodi General Partner The nNovation Group inc. www.nnovation.ca/blog --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jodi Showers wrote:> > :with => "''bucket=''+$(''crummy'').value" > > > > and it seems to work just peachy! > > that''ll work just find until you try that trick with checkboxes, > radiobuttons, selects. That''s when you want to serializeThanks! The only reason I could think not to do that is a general reticence against deeply nested inescapable quotes and delimiters. As a rule of thumb... And I think Form.serialize calls a Form.Element.serialize, or something, that''s accessible... -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---