ajax call_remote

Hello, is there something like a "call_remote" ?

I would like to execute an RJS template after a page is loaded so that it sets up the screen's hidden fields as required when Ajax is in play.

(I don't want to make certain things hidden by default as I want them to show if Javascript is disabled, and I'd prefer not to duplicate code client-side that I already have in my rjs files).

Thanks.

John Lane wrote:

Hello, is there something like a "call_remote" ?

I would like to execute an RJS template after a page is loaded so that it sets up the screen's hidden fields as required when Ajax is in play.

You can add:

<%= javascript_tag(remote_function :url => ... ) %>

to the page which will cause it to call the specified action which can send back the updates. Is this what you mean?

Sorted it like this with Javascript:

Event.observe( window, 'load', function() { <%= remote_function :url => {:action => :display_fields, :only_path => :false}%> } );

Not sure if this is the best way, but it does what I need.

Mark Bush wrote:

You can add:

<%= javascript_tag(remote_function :url => ... ) %>

Thanks Mark. My solution worked but this is what I actually wanted - I just hadn't thought of it that way. Much more elegant. Thanks!