method
remote_function
v1.1.6 -
Show latest stable
- Class:
ActionView::Helpers::PrototypeHelper
remote_function(options)public
Returns the JavaScript needed for a remote function. Takes the same arguments as link_to_remote.
Example:
<select id="options" onchange="<%= remote_function(:update => "options", :url => { :action => :update_options }) %>"> <option value="0">Hello</option> <option value="1">World</option> </select>
2Notes
Example
This function can be used to pass the ID of selected item, for example:
# with select or collection_select helpers:
{ :onchange => remote_function(:url => { :action => 'do_smth' }, :with => "'id=' + $('the_id').value") }
# and grab ID in controller action as usually:
YourModel.find(params[:id])
With multiple parameters
=== Example remote_function( :url => some_remote_function_path, :with => "'key1='+$('elem_id').value +'&key2='+$('elem_id').value+ '&this_elem_value='+value" )