From b836b2df33d8bdb03500b04bacc2849dab882d35 2014-01-16 10:57:03 From: Jonathan Frederic Date: 2014-01-16 10:57:03 Subject: [PATCH] Cleaned up _make_callbacks method of widget model class --- diff --git a/IPython/html/static/notebook/js/widget.js b/IPython/html/static/notebook/js/widget.js index f843d6d..3ac5161 100644 --- a/IPython/html/static/notebook/js/widget.js +++ b/IPython/html/static/notebook/js/widget.js @@ -355,12 +355,23 @@ define(["components/underscore/underscore-min", // Build a callback dict. _make_callbacks: function (cell) { var callbacks = {}; - if (cell != null && cell.output_area != undefined && cell.output_area != null) { + if (cell != null) { + + // Try to get output handlers + var handle_output = null; + var handle_clear_output = null; + if (cell.output_area != undefined && cell.output_area != null) { + handle_output = $.proxy(cell.output_area.handle_output, cell.output_area); + handle_clear_output = $.proxy(cell.output_area.handle_clear_output, cell.output_area); + } + + // Create callback dict usign what is known var that = this; callbacks = { iopub : { - output : $.proxy(cell.output_area.handle_output, cell.output_area), - clear_output : $.proxy(cell.output_area.handle_clear_output, cell.output_area), + output : handle_output, + clear_output : handle_clear_output, + status : function(msg){ that._handle_status(cell, msg); }, @@ -369,12 +380,7 @@ define(["components/underscore/underscore-min", // Allows us to get the cell for a message so we know // where to add widgets if the code requires it. get_cell : function() { - if (that.last_modified_view != undefined && - that.last_modified_view.cell != undefined) { - return that.last_modified_view.cell; - } else { - return null - } + return cell; }, }, };