Can Javascript code be called from with <%= %> tags

I want to make a call to remote_function with 1 of the parameters
derived from a javascript call.

For example:
<%= remote_function(:url => {:action = “xyz”, :id => getId()}, :update
=> ‘main_content’) %>

getId() is a Javascript function.

Can something like this be done?

Conversely,
can the remote_function(options) call be made from javascript.

Something like
def f()
{
var options = {“url”: {“action”: “xyz”, “id” : getId()}, “update”:
“main_content”};
remote_function(options);
}

On 28 May 2008, at 23:36, JeffB wrote:

Can something like this be done?

Yes and no. The javascript clearly cannot be evaluated at the time
that the <%= is evaluated, since that happens server side.
However, the remote_function family do take a :with option, which is a
string of javascript to be executed and bashed into the parameters
when the ajax call is made. I wrote up some of the ways of playing
with the :with option at

Conversely,
can the remote_function(options) call be made from javascript.

remote_function just generates some javascript, usually something like

new Ajax.Updater(‘some_div’, /foo/bar, {some: options}

Fred