From e927cf64545bfdb2c5473b5f97f6af2b8d07a3e5 Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Wed, 12 Apr 2017 19:46:20 -0400 Subject: [PATCH] Fix calling .remove() when in an output widget. --- widgetsnbextension/src/extension.js | 1 + widgetsnbextension/src/widget_output.js | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/widgetsnbextension/src/extension.js b/widgetsnbextension/src/extension.js index 1873d5416c4..47230911d4d 100644 --- a/widgetsnbextension/src/extension.js +++ b/widgetsnbextension/src/extension.js @@ -70,6 +70,7 @@ function register_events(Jupyter, events, outputarea) { events.on('delete.Cell', removeView); events.on('execute.CodeCell', removeView); events.on('clear_output.CodeCell', removeView); + events.on('clear_output.OutputArea', removeView); /** * Render data to the output area. diff --git a/widgetsnbextension/src/widget_output.js b/widgetsnbextension/src/widget_output.js index 61cf340cd17..df01aa68754 100644 --- a/widgetsnbextension/src/widget_output.js +++ b/widgetsnbextension/src/widget_output.js @@ -66,7 +66,7 @@ var OutputView = widgets.DOMWidgetView.extend({ render: function(){ var that = this; - var renderOutput = function(outputArea) { + var renderOutput = function(outputArea, events) { that.output_area = new outputArea.OutputArea({ selector: that.el, // use default values for the output area config @@ -79,7 +79,8 @@ var OutputView = widgets.DOMWidgetView.extend({ }, that); that.listenTo(that.model, 'clear_output', function(msg) { that.output_area.handle_clear_output(msg); - }) + events.trigger('clear_output.OutputArea', {cell: {output_area: that.output_area}}) + }); // Render initial contents from that.model._outputs that.model._outputs.forEach(function(msg) { @@ -87,7 +88,7 @@ var OutputView = widgets.DOMWidgetView.extend({ }, that) } - requirejs(["notebook/js/outputarea"], renderOutput) + requirejs(["notebook/js/outputarea", "base/js/events"], renderOutput) }, });