Reputation: 3802
I have comments for posts in a rails site.
Here is my _form.html.slim for my "make a new comment" form.
I would like pressing the enter key to submit the form and the submit button to be hidden/not displayed.
Is this possible within simpleform?
span = simple_form_for([@post, @post.comments.build], :defaults => { :input_html => { :class => "comment-input-text" } }) do |f|
= f.input :comment, label: false, placeholder: "Add a comment"
= f.submit
Sorry, I could not convert this code the any erb or html. If anyone would like to edit this question and put in the erb it would be much appreciated.
Upvotes: 0
Views: 1435
Reputation: 6311
Actually, its duplicate question
Check this link: Submit form with Enter key without submit button?
You can add this right below form
javascript:
$("input").keypress(function(event) {
if (event.which == 13) {
event.preventDefault();
$("form_id_here").submit();
}
});
Upvotes: 1