title: Rails action cable, Input doesn't get cleared after POST
body: <p>I had this code and was working fine, just notices that the 'event.keyCode' is depricated as VScode saying</p>
  <pre><code>
  consumer.subscriptions.create(&quot;CommentsChannel&quot;, {
    connected() {
      // Called when the subscription is ready for use on the server
    },
  
    disconnected() {
      // Called when the subscription has been terminated by the server
    },
  
    received(data) {
      console.log(data.content)
      $('#comments').append('&lt;strong&gt;' + data.content[1] + ': ' + '&lt;/strong&gt;' + data.content[0] + ' ' + data.content[2] + ' &lt;hr class=&quot;comments-hr&quot;&gt;' )
      // Called when there's incoming data on the websocket for this channel
    }
  });
  
  var submit_messages;
  
  $(document).on('turbolinks:load', function() {
    submit_messages()
  })
  
  submit_messages = function (){
    $('#new_comment').on('keydown', function (event){
      if(event.keyCode === 13){
        $('#send_button').click()
        event.target.value = ''
        event.preventDefault()
      }
    })
  }
  </code></pre>
  <p>so i chagnged it to</p>
  <pre><code>submit_messages = function (){
    $('#new_comment').on('keydown', function (event){
      if(event.key === 'Enter'){
        $('#send_button').trigger( &quot;click&quot; )
        event.target.value = ''
        event.preventDefault()
      }
    })
  </code></pre>
  <p>so the problem i face now with the both options above is that the input doesn't get cleared after i press the button or clear press enter</p>
  <p><a href="https://i.stack.imgur.com/zKeFk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zKeFk.png" alt="enter image description here" /></a></p>
  <p>if use this</p>
  <pre><code>$('#comment_field').val('')
  </code></pre>
  <p>and press enter  i don't get the value at all but i do when i click the button</p>
  <p><a href="https://i.stack.imgur.com/1CAbB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1CAbB.png" alt="enter image description here" /></a></p>
  <p>this is the model</p>
  <pre><code>
      def self.post_comment(new_comment,ticket,user)
          ticket.comment.tap do |post_new_comment|
              post_new_comment.content &lt;&lt; new_comment
              post_new_comment.username &lt;&lt; user
              post_new_comment.sendtime &lt;&lt; Time.now
                  if post_new_comment.save
                      ActionCable.server.broadcast 'comments_channel', content: [new_comment, user, Time.now.strftime(&quot;%H:%M:%S&quot;)]
                  end
          end
      end
  
  </code></pre>
  <p>the input field</p>
  <pre><code>        &lt;%= f.text_field :comment, class: &quot;form-control&quot;, placeholder: &quot;Write a Comment&quot;, id: &quot;comment_field&quot; if @ticket.status%&gt;
  </code></pre>
  <p>and the button</p>
  <pre><code>    def submit_comment_button
          content_tag(:button, class: &quot;btn btn-sm btn-primary&quot;, id: &quot;send_button&quot;) do
              content_tag(:i, class: &quot;bi bi-arrow-right-square&quot;) do
              end
          end  
      end
  </code></pre>