Topic: Form submission via javascript

I can submit form in javascript with


Is there a way in javascript to pass some values with this trigger? I'd need something like "back_button" in

<%= f.submit "Back", class: "btn", :name => "back_button" %>

to handle it in submit action in controller.

Thank you for help

Re: Form submission via javascript

Indeed neither .trigger() nor .submit() send the button's name attribute along.  What about adding a hidden form field or changing the form's action attribute?  ( … t-not-ajax)

You could also hijack the submission itself: … submission

Re: Form submission via javascript

Thank you for hints. A day of google and testing I found a working sollution. For those who may encounter the same problem here is the code:

var data = $("#my_form_id").serializeArray();

$.post("url_for_submit", $.param(data), null, "script");