var submit_messages;

$(document).on('turbolinks:load', function () {
    submit_messages()
})

submit_messages = function () {
    $('#message_content').on('keyDown', function (event) {
        if (event.keyCode === 13) {
            $('input').click()
            event.target.value = ''
            event.preventDefault()
            console.log('yes we hit enter!')
        }
        
    })
    
}

I got this from a youtube video titled Rails 6 - Real Time Chat App What 
doesn't make sense to me is why do we only clear the field if the enter key 
is pressed, why doesn't that work anyway (it doesn't clear the field) and 
why doesn't it log to console 'yes we hit enter!'

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/5c7f7223-915d-4960-89ad-5f3bd030568b%40googlegroups.com.

Reply via email to