Merge pull request #29 from kevgathuku/patch-1

Chat example: Only send message if generalChannel is available
This commit is contained in:
Jeff Linwood
2017-11-21 08:33:37 -05:00
committed by GitHub

View File

@@ -98,7 +98,7 @@ $(function() {
// Send a new message to the general channel // Send a new message to the general channel
var $input = $('#chat-input'); var $input = $('#chat-input');
$input.on('keydown', function(e) { $input.on('keydown', function(e) {
if (e.keyCode == 13) { if (e.keyCode == 13 && generalChannel) {
generalChannel.sendMessage($input.val()) generalChannel.sendMessage($input.val())
$input.val(''); $input.val('');
} }