Forum: Ruby on Rails help on submit_to_remote

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5374b14d364988d824b3f7f5c3c6625d?d=identicon&s=25 olivier Hericord (Guest)
on 2005-12-30 22:00
(Received via mailing list)
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
B554bcde846e4497eeffffc1399d3b09?d=identicon&s=25 Benjamin Stiglitz (Guest)
on 2005-12-31 00:49
(Received via mailing list)
> 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 <button> 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 <submit>, 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 <button>s inside
a single form with different a different value for the :url hash.

Example:
<form>
   <label for="field1">Field 1:</label> <input id="field1"
type="text" name="field1" /><br />
   <label for="field2">Field 2:</label> <input id="field2"
type="text" name="field2" /><br />
   <%= submit_to_remote 'button', 'button1', :url => { :action =>
'create' } -%>
   <%= submit_to_remote 'button', 'button2', :url => { :action =>
'lookup' } -%>
</form>

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
5374b14d364988d824b3f7f5c3c6625d?d=identicon&s=25 olivier Hericord (Guest)
on 2005-12-31 01:49
(Received via mailing list)
thanks Ben
This topic is locked and can not be replied to.