Ajax/Rails question

Is there any way to make an Ajax call (like link_to_remote) and pass in
the value of a field on screen? This seems obvious, but I can’t find
anything…

Thanks,
Marcus

Marcus B. wrote:

Is there any way to make an Ajax call (like link_to_remote) and pass in
the value of a field on screen? This seems obvious, but I can’t find
anything…

You could not use the helper and do this:

link

Where url is the url of your controller/action and pars are the params
you wanna pass.

or write your own helper that does this. Didn’t see a way to do it with
the existing one.

:slight_smile:

Michael T. wrote:

He’s probably talking about the field value at the time the link is
clicked. This can be done with the :with => parameter. Look into it.

ah… would be nice if the api docs had that as part of link_to_remote
options.

Found it under observe_field

:with
“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.”

Thanks! will try that.

He’s probably talking about the field value at the time the link is
clicked. This can be done with the :with => parameter. Look into it.
If you need more help let me know.

Michael