From 24ec0da125ce0ec6db48b80f503cf6bf9ad3c019 Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Fri, 10 Jan 2014 00:53:40 -0500 Subject: [PATCH] Fix the cell reference in views This solution is kludgy, but it does fix what broke when we tried to take the cell references out of views. Conflicts: IPython/html/static/notebook/js/widgets/widget.js --- IPython/html/static/notebook/js/widgetmanager.js | 5 ++--- IPython/html/static/notebook/js/widgets/widget.js | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/IPython/html/static/notebook/js/widgetmanager.js b/IPython/html/static/notebook/js/widgetmanager.js index 524f7b037..f2386207f 100644 --- a/IPython/html/static/notebook/js/widgetmanager.js +++ b/IPython/html/static/notebook/js/widgetmanager.js @@ -78,12 +78,11 @@ console.log("Could not determine where the display" + " message was from. Widget will not be displayed"); } else { - var view = this.create_view(model); + var view = this.create_view(model, {cell: cell}); if (view !== undefined && cell.widget_subarea !== undefined && cell.widget_subarea !== null) { - view.cell = cell; cell.widget_area.show(); cell.widget_subarea.append(view.$el); } @@ -141,7 +140,7 @@ WidgetManager.prototype.callbacks = function (view) { // callback handlers specific a view var callbacks = {}; - var cell = view.cell; + var cell = view.options.cell; if (cell !== null) { // Try to get output handlers var handle_output = null; diff --git a/IPython/html/static/notebook/js/widgets/widget.js b/IPython/html/static/notebook/js/widgets/widget.js index e5d68c70a..2b13062c5 100644 --- a/IPython/html/static/notebook/js/widgets/widget.js +++ b/IPython/html/static/notebook/js/widgets/widget.js @@ -226,8 +226,14 @@ function(widget_manager, underscore, backbone){ create_child_view: function(child_model, options) { // Create and return a child view. // - // - given a model and (optionally) a view name if the view name is + // -given a model and (optionally) a view name if the view name is // not given, it defaults to the model's default view attribute. + + // TODO: this is hacky, and makes the view depend on this cell attribute and widget manager behavior + // it would be great to have the widget manager add the cell metadata + // to the subview without having to add it here. + options = options || {}; + options.cell = this.options.cell; var child_view = this.model.widget_manager.create_view(child_model, options); this.child_views[child_model.id] = child_view; return child_view;