Send As SMS
Transcraft Blog
The choice of the IT professionals

Monday, January 09, 2006

Post a whole form contents back in an AJAX call in Ruby on Rails

Rails has a ready made call which facilitates passing the contents of all the elements in a form in an AJAX call with the call form_remote_tag

form_remote_tag :html => { :action => url_for(:controller => "some", :action => "place") }

However, the problem with the above method is you can not pass the name of the form into the call, so if you have multiple forms on your page, this is the way to do it:

<form name='logon' id='logon'>
<input name='name' />
<input type='password' name='pass' />
<%= link_to_remote "Log me in",
:url => { :action => 'authenticate' },
:with => "Form.serialize($('logon'))",
%>
</form>
Extracted from Tips and Tricks

posted by David at 2:01 PM

1 Comments:

Anonymous said...

form_remote_tag(:url => { :action => 'authenticate' }, :html => { :name => 'logon' })

9:25 PM  

Post a Comment

Links to this post:

Create a Link

<< Home

Home
Contact us

Previous Posts

links to this post

Powered by Blogger