Forum: Ruby on Rails Disabling observe_form AJAX request on submit button click?

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.
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2008-11-03 21:39
All,

I have a form that is using observe_form to periodically check for
modifications to the form and submit an AJAX request.  It works really
well.

However, by watching Firebug output, I notice that the AJAX request
always fires when I click the submit button, and even when nothing has
changed on the form.

Is there any way to suppress the firing of this AJAX request when the
submit button on the form is clicked?

Thanks,
Wes
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2008-11-03 21:49
Hijacking the click handler by adding this:

  :onclick => 'this.form.submit(); return false'

to the submit_tag() call for the submit button seems to work well.

Wes
Db7238007950074e9e73b76a81910406?d=identicon&s=25 tonypm (Guest)
on 2008-11-05 07:56
(Received via mailing list)
I had a similar thing with a form whithout a submit button.  I wanted
to use form observer.  The form only had select fields (and an
autocomplete field).

If I hit enter, the form gets submitted, even if the cursor is in the
autocomplete field.  Never did quite figure it  out but got round it
by using field observers instead.  It seemed like the focus
iinternally in the form was in a virtual submit button.  If I add a
normal text field, the problem goes away.

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