3

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?

2 Answers 2

8

This seems to work:

$(this.form).submit();

Good 'ol jquery to the rescue.

Sign up to request clarification or add additional context in comments.

1 Comment

Be warned this will only work if you only have one form element on your page
1

This is simply in Rails way :

 $("#myform").trigger('submit.rails');

find it here : same question

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.