Skip to content

Instantly share code, notes, and snippets.

@mfifth
Created February 28, 2017 19:34
Show Gist options
  • Select an option

  • Save mfifth/30df68bccd890a40f589d8b6c1623f7c to your computer and use it in GitHub Desktop.

Select an option

Save mfifth/30df68bccd890a40f589d8b6c1623f7c to your computer and use it in GitHub Desktop.
$(document).on "turbolinks:load", ->
$('#new_message').on "keypress", (e)->
if e && e.keyCode == 13
e.preventDefault()
$(this).submit()
$("#new_message").on "submit", (e) ->
e.preventDefault()
chatroom_id = $("[data-behavior='messages']").data("chatroom-id")
body = $("#message_body")
window.scrollTo(0, document.body.scrollHeight);
App.chatrooms.send_message(chatroom_id, body.val())
body.val("")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment