0

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.

Rorschach
  • 3,104
  • 3
  • 24
  • 60

1 Answers1

1

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();
    }
  });
Community
  • 1
  • 1
7urkm3n
  • 5,296
  • 2
  • 23
  • 43