Help on submit_to_remote


#1

hi,

read the API doc and made search with google but can’t get a precise
explanation on how submit_to_remote work.

can someone help on that?

thanks


#2

read the API doc and made search with google but can’t get a precise
explanation on how submit_to_remote work.

It creates a tag that uses an XMLHttpRequest (boy, does that
capitalization bother me) to submit the form the button’s contained
in. Note that it’s different than a , since it won’t do
anything if the user has JavaScript disabled. It can be used to
submit the same form to two different actions, or using different
params, by inserting two different submit_to_remote s inside
a single form with different a different value for the :url hash.

Example:

Field 1:
Field 2:
<%= submit_to_remote 'button', 'button1', :url => { :action => 'create' } -%> <%= submit_to_remote 'button', 'button2', :url => { :action => 'lookup' } -%>

You’ll be able to check both @params[‘button’] (yielding either
‘button1’ or ‘button2’) or differentiate on the action.

Hope this helps; feel free to ask if you have more questions.

-Ben


#3

thanks Ben