From 982f72b4ba5c82076ce0f6ebcbbe5f6c5011a103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Bokros?= Date: Mon, 27 Nov 2017 19:00:02 +0100 Subject: [PATCH] Rework button handler --- src/app/static/ws_listener.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/app/static/ws_listener.js b/src/app/static/ws_listener.js index 89cd1eb..3909d81 100644 --- a/src/app/static/ws_listener.js +++ b/src/app/static/ws_listener.js @@ -2,13 +2,16 @@ let ws = new WebSocket('ws://' + document.location.host + '/ws'); $('#container').on('click', '.anchor', ( function (event) { + let anchorName = $(this).attr('id').replace('_event', ''); + let data = JSON.stringify({ + 'anchor': anchorName, + 'data': $('#' + anchorName).text() + }); + console.log('Sending: '); + console.log(data); + ws.send(data); +})); let anchorName = $(this).attr('id').replace('_event', ''); - let data = JSON.stringify({ - 'anchor': anchorName, - 'data': $('#' + anchorName).text() - }); - console.log("Sending: " + data); - ws.send(data); })); ws.onmessage = function (messageEvent) {