I want to append an li to a ul when a user disconects. (user has disconnected).
I don't know what's wrong with my code but I can't get the event to fire.
Here's my server.js
socket.on('disconnect', function(data) {
users.splice(users.indexOf(socket), 1);
console.log('User Disconnected: %s users connected.', users.length);
io.sockets.emit('counter', {users : users.length});
})
Which console.logs and counts the users without a problem. But when I try using the same call on the client.js:
socket.on('disconnect', function () {
$('#output').append('<li class="collection-item red-text">User has
disconnected</li>');
})
Nothing gets appended to the UL. I'm probably missing something but can't see what. Any help appreciated!