I often use js / jquery to submit forms. This is very useful if the submit button is outside the form or if there is more than one button that submits the same form.
$(".submit-btn").click(function(event) { event.preventDefault(); $("#form-id").submit(); });
event.preventDefault(); prevents the default / submit button behavior.
Here is the coffeescript example that I used in the rails 4 project:
ready = -> if $("#form-id").length > 0 $(".submit-btn").click (event) -> event.preventDefault() $("#form-id").submit() $(document).ready ready $(document).on "page:load", ready
Also note: in this way, the link can be any type of element - optionally a submit button. You do not need to have a submit button inside the form, but if you run preventDefault , this will prevent the default form preventDefault behavior.
jverban
source share