Whenever I click on my send button, the emit event doesn't trigger consistently (sometimes it triggers, sometimes it doesn't). It does trigger when I spam click on my send button.
Here is my server.py
@socketio.on('message')
def message(message_data):
print(message_data)
room = message_data['channel']
emit('broadcast', message_data, room=room)
And here is my client.js which is supposed to trigger the send event
socket.on('connect', function (){
socket.emit('join channel', {
'channel_id': localStorage.getItem('channel_id')
})
})
$("#send").on('click', function (){
prevent_blank_text()
socket.emit('message',{
'message': $("#message").val(),
'user': localStorage.getItem('channel_user'),
'channel': localStorage.getItem('channel_id'),
'timestamp': new Date().toLocaleString()
}, function (){
$("#message").val('')
})
})
Note: the connect event is decoupled from the click event, I just included it there just in case that's where the problem is stemming from.
Could someone point me in the right direction?
EDIT: Apparently bootstrap's btn-large is what's causing the problem, it wasn't a socketio problem
<button type="button" id="send" class="btn btn-success">Send</button>
This fixed my send button