0

In Rails 5 application I have a form which is not being submitted correctly on Edge, due to submit input being placed outside of the form. Is there any way I can handle it without changing my html structure to actually have input inside the form?

TylerH
  • 19,065
  • 49
  • 65
  • 86
Leo
  • 1,907
  • 4
  • 26
  • 47

1 Answers1

1

I am afraid that if you don't want to move the submit button into the form (although I don't really understand why would you want the button to be outside of <form> tags), you can submit the form by Javascript.

Just call submit method on form after the button has been clicked. Using jQuery, it would look something like this:

$("#my-button").on("click", function() {
  $("my-form").submit();
});
Marek Takac
  • 2,722
  • 21
  • 28
  • and how do i do that for Edge only? – Leo Aug 09 '17 at 14:16
  • Theoretically you could run the Javascript code only if user's browser is edge. See https://stackoverflow.com/questions/31721250/how-to-target-windows-10-edge-browser-with-javascript for example. BUT I would strongly recommend against doing so. Submit the form in same way across all browsers. – Marek Takac Aug 09 '17 at 14:21