Merge pull request #51 from beatriceo/chat-room

added message sending
This commit is contained in:
Beatrice Olivera 2018-09-04 11:49:41 +01:00 committed by GitHub
commit 77d92b4fdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -19,17 +19,18 @@ App['chatroom' + chatroomId] = App.cable.subscriptions.create({
connected: () => {
},
received: data => {
console.log(data)
}
})
// Testing ActionCable
// const testBtn = document.getElementById('test-btn')
// testBtn.addEventListener('click', event => {
// fetch(`/chat_rooms/${chatroomId}/cable_testing` , {
// method: 'POST',
// body: JSON.stringify({})
// })
// })
const testBtn = document.getElementById('test-btn')
testBtn.addEventListener('click', event => {
fetch(`/chat_rooms/${chatroomId}/cable_testing` , {
method: 'POST',
body: JSON.stringify({})
})
})

View File

@ -1,3 +1,4 @@
<button id="test-btn" class="btn btn-primary">Test Connection</button>
<div id="join-btn" data-room="<%= @chat_room.id %>"></div>
<div id="chatroom-hook" data-chatroom-id='<%= @chat_room.id %>'></div>