Topic: link_to_remote parameters

Hi,

Does anyone knows how I can get values from input items and add them to the link_to_remote params?

like:

<select name="selectbox" id="selectbox">
<option id="1">Option1</option>
<option id="2">Option2</option>
<option id="3">Option3</option>
</select>
<input type="text" name="textField" id="textFieldID" />
[link_to_remote]

I use a remote_form now, but that's not possible anymore.

Nested forms does not work very well smile

Any help is highly appreciated.

Peter.

Re: link_to_remote parameters

Inside any javascript you can attach this little snipped which will grab the value of anything with the right 'id':

$('selectbox').value

Re: link_to_remote parameters

Or you can use the shorter method:

$F("someformfield");

Re: link_to_remote parameters

Briliant ! Thanks.

Now I only have to find how I can implement that in the link_to_remote.

edit:

<%= link_to_remote "add", :url=>{ :action => :add_material_new, :index => index },:with=> "'material_name='+$F('material_name')" %>

The :with does the trick!

P.

Last edited by NeXoPheuS (2007-01-27 08:31:51)

Re: link_to_remote parameters

Wow! You can use :with in link_to_remote? Why don't they document these things? *sigh*

Good find. That's very nice to know. I wonder what other AJAXy methods support :with and don't specify in the docs.

Railscasts - Free Ruby on Rails Screencasts