added message sending

This commit is contained in:
Beatrice Olivera 2018-09-04 11:49:18 +01:00
parent a48f955914
commit 083ec3e747
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>