diff --git a/IPython/html/static/notebook/js/widgetmanager.js b/IPython/html/static/notebook/js/widgetmanager.js index 2526640..ca1b9f7 100644 --- a/IPython/html/static/notebook/js/widgetmanager.js +++ b/IPython/html/static/notebook/js/widgetmanager.js @@ -90,10 +90,18 @@ } }, - WidgetManager.prototype.create_view = function(model, options) { + WidgetManager.prototype.create_view = function(model, options, view) { var view_name = model.get('view_name'); var ViewType = WidgetManager._view_types[view_name]; if (ViewType !== undefined && ViewType !== null) { + + // If a view is passed into the method, use that view's cell as + // the cell for the view that is created. + options = options || {}; + if (view !== undefined) { + options.cell = view.options.cell; + } + var parameters = {model: model, options: options}; var view = new ViewType(parameters); view.render(); diff --git a/IPython/html/static/notebook/js/widgets/widget.js b/IPython/html/static/notebook/js/widgets/widget.js index 7a8a2aa..f9dd448 100644 --- a/IPython/html/static/notebook/js/widgets/widget.js +++ b/IPython/html/static/notebook/js/widgets/widget.js @@ -261,7 +261,7 @@ function(WidgetManager, Underscore, Backbone){ // 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. - var child_view = this.model.widget_manager.create_view(child_model, options || {}); + var child_view = this.model.widget_manager.create_view(child_model, options || {}, this); this.child_views[child_model.id] = child_view; return child_view; },