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
> 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
thanks Ben On 12/31/05, Benjamin Stiglitz <ben@tanjero.com> wrote:> > 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Maybe Matching Threads
- form_remote_tag can only have one submit button?
- Help on implementing rails from html with php
- rspec model testing - test on user defined validation- How do I test that the create failed.
- I need "validates_presence_of" help
- RJS Templates not conducting callbacks