Forum: Ruby on Rails form :onblur => 'this.form.submit()' doesn't do AJAX

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.
Jeroen H. (Guest)
on 2006-05-03 21:07
(Received via mailing list)
Hi,

I'm looking to create a form that gets submitted using AJAX after an
element loses focus.

<% remote_form_for :person, @person, :url => { :action => "save" },
:update => 'form' do |f| %>

<label for="person_fname"><span class="req">*</span>Name</label>
<div class="form_el">
<%= f.text_field :naam, :size=>50, :onblur => 'this.form.submit()'  %>
</div>

<% end %>

This doesn't work though, it submits the form using a plain old POST.
Any ideas on how to accomplish this?

Thanks in advance,

Jeroen
Jeroen H. (Guest)
on 2006-05-03 21:07
(Received via mailing list)
Jeroen H. wrote:
> Hi,
>
> I'm looking to create a form that gets submitted using AJAX after an
> element loses focus.
>

This seems to work:

<%= f.text_field :name, :size=>50,
:onblur => remote_function(:update => "form",
:with => 'Form.serialize(this.form)',
:url => { :action => :presubmit })  %>

Cheers,

Jeroen
This topic is locked and can not be replied to.