Evaluate javascript in Ajax.Request

Hi there,

does anyone know if it is possible to generate remote_function calls in a dynamic fashion similar to this:

<%= remote_function(:url => {:action => "setComponent", :component => comp, :value => document.getElementById("...").value})%>

where I don't want to evaulate the document.getElementById part but rather want to pass this javascript code to the Ajax.Request object for later evaluation.

The problem here is that the document.getElementById("...").value part is passed to the resulting Ajax.Request object as a string:

new Ajax.Request('/epacs/setComponent?component=3&value=document.getElementById(...).value', {asynchronous:true, evalScripts:true})

and seems to be never evaluated but rather passed to the server as a string.

How do I create this remote_function call so that the javascript is evaluated at the very same time that the Ajax.Request is fired?

Thanks a lot!

Hi there,

does anyone know if it is possible to generate remote_function calls
in a dynamic fashion similar to this:

<%= remote_function(:url => {:action => "setComponent", :component => comp, :value => document.getElementById("...").value})%>

where I don't want to evaulate the document.getElementById part but rather want to pass this javascript code to the Ajax.Request object
for later evaluation.

The problem here is that the document.getElementById("...").value part is passed to the resulting Ajax.Request object as a string:

new Ajax.Request('/epacs/setComponent? component=3&value=document.getElementById(...).value', {asynchronous:true, evalScripts:true})

and seems to be never evaluated but rather passed to the server as a string.

You need to use the :with option (ie remote_function :url =>
{...}, :with => ...)

Fred.