Simple example:
<%= form_for :post, url: posts_path do |f|%>
<p>
<%= f.label :title%><br/>
<%= f.text_field :title%>
</p>
<p>
<%= f.label :text%><br/>
<%= f.text_area :text%>
</p>
<p>
<%= f.submit%>
</p>
<%end%>
I think this is a Rails default event handling. In here, if the user presses the enter key, it submits the params
.
But in my case, I have to use the enter key for another event.
I have to search users
with another input field by pressing the enter key.
But if I use form_for
it submits the form. :(
How can I prevent submitting with the enter key in rails
?
Do I have to use plain html tags? Like <form> tag
and <submit> button
?
Any good solutions?