Form :onblur => 'this.form.submit()' doesn't do AJAX


#1

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| %>

*Name

<%= f.text_field :naam, :size=>50, :onblur => 'this.form.submit()' %>

<% 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


#2

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