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
> :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
Thanks! 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...