dynamically create rooms chatboxes
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
const socket = io();
|
||||
const form = document.getElementById('form');
|
||||
const input = document.getElementById('input');
|
||||
|
||||
form.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
if (input.value) {
|
||||
socket.emit('chat message', input.value);
|
||||
input.value = '';
|
||||
}
|
||||
});
|
||||
export function create_listener(form, input) {
|
||||
form.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
if (input.value) {
|
||||
socket.emit('chat message', input.value, form.id);
|
||||
input.value = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user