Setting parameters in link from javascript

Hi.

I need to do an Ajax call to populate a span-tag with some text from the server-side. I'm using 'link_to_remote' but I need to fetch one of the parameters in the call from a form field.

Initially I tried something like:

<%= link_to_remote '....', :url => {:action => 'some_action', :id => '$ (some_form_field).value;'}, :update => 'target_span' %>

This will obviously not work.

But - is there an easy way to do this using the Rails helpers? I suppose it would be possibly by writing some custom Javascript - but I'm trying to avoid that.

Best Regards //Anders

I'll go ahead and answer my own question :slight_smile:

I managed to solve my specific problem by using the 'submit' parameter:

<%= link_to_remote '....', :url => {:action => 'some_action'}, :update => 'target_span', :submit => 'id_of_container_holding_the_input_form' %>

See http://wiki.script.aculo.us/scriptaculous/show/Ajax.Updater where the 'submit' parameter is described.

//Anders

That's exactly what I was looking for!

I couldn't find the description on the script.aculo.us-wiki. Could you (or anyone else) point me to a website where the usage of link_to_remote's :submit-parameter is described? The rails API-docs arent very substantial regarding this...

My main-question is: How do I fetch the submitted parameter in the controller method? Using params[:submit]?