What does :with do in _remote calls, like link_to_remote() or
periodically_call_remote()?
The documentation says :with should point to:
'A JavaScript expression specifying the parameters for the
XMLHttpRequest. This defaults to 'value', which in the evaluated
context refers to the new field value. If you specify a string without
a "=", it'll be extended to mean the form key that the value should be
assigned to. So :with => "term" gives "'term'=value". If a "=" is
present, no extension will happen.'
What does all that mean??
I need to take the value from a hidden field and pass this with the
_remote call. Is that what with is for? When I naively turn it on
(with the name of the hidden field as a string) the
periodically_call_remote() stops working.
Someone had to tell me "the remote caller will evaluate the :with
target as javascript, hence it can pull live data from your DOM."
:with => 'id_of_hidden_field' didn't work, and I suppose I could have
done something like 'document.all.id_of.value'. But your scriptalicious
Form.Element.serialize() worked.
I'm not sure why it puts a "_"=>nil into the params, though, but that's
too small to be worth optimizing away!
in your remote to pass on the value of a hidden field with an ID of "hidden_id" with your _remote call. It will be available in your method as params['name'].