From 0e2bfcad3d64af7df2f304cefa7e4e2c749189bf Mon Sep 17 00:00:00 2001 From: Andrea Bedini Date: Mon, 19 Aug 2013 15:50:54 +1000 Subject: [PATCH] Fix wrong binding of JS this inside the closure this binds to the WebSocket object rather than to the figure object. --- lib/matplotlib/backends/web_backend/mpl.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/backends/web_backend/mpl.js b/lib/matplotlib/backends/web_backend/mpl.js index f9d9761801cc..5a46daa8bbd7 100644 --- a/lib/matplotlib/backends/web_backend/mpl.js +++ b/lib/matplotlib/backends/web_backend/mpl.js @@ -54,15 +54,15 @@ figure.prototype.finalize = function (canvas_id_prefix, toolbar_id_prefix, messa this.format_dropdown = document.getElementById(toolbar_id_prefix + '-format_picker'); + var fig = this; this.ws.onopen = function () { - this.ws.send(JSON.stringify( + this.send(JSON.stringify( {type: 'supports_binary', - value: this.supports_binary})); + value: fig.supports_binary})); } // attach the onload function to the image object when an // image has been recieved via onmessage - fig = this onload_creator = function(fig) {return function() {fig.context.drawImage(fig.imageObj, 0, 0);};}; this.imageObj.onload = onload_creator(fig);