From cea07fb351850cc124179733bb9ceb695e454201 Mon Sep 17 00:00:00 2001 From: MinRK Date: Sun, 21 Jul 2013 10:40:09 -0700 Subject: [PATCH] bind kernel events in Kernel.bind_events avoids multiple-register of send_input event --- IPython/html/static/services/kernels/js/kernel.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/IPython/html/static/services/kernels/js/kernel.js b/IPython/html/static/services/kernels/js/kernel.js index 98d744c4c..48b9b92e1 100644 --- a/IPython/html/static/services/kernels/js/kernel.js +++ b/IPython/html/static/services/kernels/js/kernel.js @@ -42,6 +42,7 @@ var IPython = (function (IPython) { } else { alert('Your browser does not have WebSocket support, please try Chrome, Safari or Firefox ≥ 6. Firefox 4 and 5 are also supported by you have to enable WebSockets in about:config.'); }; + this.bind_events(); }; @@ -59,6 +60,13 @@ var IPython = (function (IPython) { }; return msg; }; + + Kernel.prototype.bind_events = function() { + var that = this; + $([IPython.events]).on('send_input_reply.Kernel', function(evt, data) { + that.send_input_reply(data); + }); + } /** * Start the Python kernel @@ -176,10 +184,6 @@ var IPython = (function (IPython) { this.shell_channel.onmessage = $.proxy(this._handle_shell_reply, this); this.iopub_channel.onmessage = $.proxy(this._handle_iopub_reply, this); this.stdin_channel.onmessage = $.proxy(this._handle_input_request, this); - - $([IPython.events]).on('send_input_reply.Kernel', function(evt, data) { - that.send_input_reply(data); - }); }; /**