Saturday, April 13, 2024
131
rated 0 times [  137] [ 6]  / answers: 1 / hits: 15978  / 9 Years ago, sat, november 14, 2015, 12:00:00

I want to convert below code to form_for or form_tag.



<form onsubmit=foo()>


What should I do? I don't want to connect another page(action=/URL).



I just want function foo() to fire when this form is submitted.


More From » ruby-on-rails

 Answers
24

This should be easy to do with either form_tag or form_for. Example:



<%= form_for @model, :html => { :onsubmit => foo() } %>
<% end %>


or



<%= form_tag '#', :html => { :onsubmit => foo() } %>
<% end %>

[#64402] Wednesday, November 11, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brandon

Total Points: 393
Total Questions: 106
Total Answers: 106

Location: Aland Islands
Member since Wed, Nov 17, 2021
2 Years ago
;