Rails remote form submit through javascript

ajax, ruby, ruby-on-rails, ruby-on-rails-3

Solution

This seems to work:

$(this.form).submit();

Good 'ol jquery to the rescue.

Problem

I'm trying to create a very small simple form that edits a single checkbox, and submits automatically with AJAX when the checkbox is modified. Here's the code, which other SO questions imply should work: ``` <%= form_for(workitem, :remote => true) do |f| %> <%= f.check_box :is_complete, :onchange => 'this.form.submit()' %> <% end %> ``` The problem is that this results in a full page HTML submit, rather than an AJAX submit. How do I trigger an AJAX submit?

Original source

Related problems