Forum: Ruby on Rails Setting parameters in link from javascript

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
61ddaf7702fb0a4bff8f7345c958319c?d=identicon&s=25 Anders Engström (Guest)
on 2007-04-24 09:42
(Received via mailing list)

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
61ddaf7702fb0a4bff8f7345c958319c?d=identicon&s=25 Anders Engström (Guest)
on 2007-04-24 13:44
(Received via mailing list)
I'll go ahead and answer my own question :)

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

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

See where
the 'submit' parameter is described.

60a3df689ea2a20d11d3986e02f9b7d1?d=identicon&s=25 Javier_CH (Guest)
on 2007-05-01 21:38
(Received via mailing list)
That's exactly what I was looking for!

I couldn't find the description on the 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]?
This topic is locked and can not be replied to.