From a0c1d37224ce69eee7743c2fb84eaa3918062eb2 Mon Sep 17 00:00:00 2001 From: "Brian E. Granger" Date: Thu, 8 May 2014 12:06:20 -0500 Subject: [PATCH] Remove model from WidgetManager._model on comm:close. --- IPython/html/static/widgets/js/manager.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/IPython/html/static/widgets/js/manager.js b/IPython/html/static/widgets/js/manager.js index 66f8090f6..d1af78c0a 100644 --- a/IPython/html/static/widgets/js/manager.js +++ b/IPython/html/static/widgets/js/manager.js @@ -197,9 +197,13 @@ WidgetManager.prototype._handle_comm_open = function (comm, msg) { // Handle when a comm is opened. + var that = this; var model_id = comm.comm_id; var widget_type_name = msg.content.target_name; var widget_model = new WidgetManager._model_types[widget_type_name](this, model_id, comm); + widget_model.on('comm:close', function () { + delete that._models[model_id]; + }); this._models[model_id] = widget_model; };