diff --git a/IPython/html/static/notebook/js/widgetmanager.js b/IPython/html/static/notebook/js/widgetmanager.js
index d35bbf1..b3640e2 100644
--- a/IPython/html/static/notebook/js/widgetmanager.js
+++ b/IPython/html/static/notebook/js/widgetmanager.js
@@ -98,8 +98,7 @@
if (ViewType !== undefined && ViewType !== null) {
var view = new ViewType({model: model, widget_manager: this, cell: cell});
view.render();
- //this.views.push(view);
-
+ model.views.push(view);
/*
// jng: Handle when the view element is remove from the page.
// observe the view destruction event and do this. We may need
diff --git a/IPython/html/static/notebook/js/widgets/base.js b/IPython/html/static/notebook/js/widgets/base.js
index 09d5298..675f98d 100644
--- a/IPython/html/static/notebook/js/widgets/base.js
+++ b/IPython/html/static/notebook/js/widgets/base.js
@@ -29,6 +29,7 @@ function(widget_manager, underscore, backbone){
this.msg_throttle = 3;
this.msg_buffer = null;
this.id = widget_id;
+ this.views = [];
if (comm !== undefined) {
// Remember comm associated with the model.
@@ -43,7 +44,6 @@ function(widget_manager, underscore, backbone){
return Backbone.Model.apply(this);
},
-
send: function (content, callbacks) {
if (this.comm !== undefined) {
@@ -55,6 +55,7 @@ function(widget_manager, underscore, backbone){
// Handle when a widget is closed.
_handle_comm_closed: function (msg) {
// jng: widget manager should observe the comm_close event and delete views when triggered
+
this.trigger('comm:close');
delete this.comm.model; // Delete ref so GC will collect widget model.
delete this.comm;
@@ -178,6 +179,7 @@ function(widget_manager, underscore, backbone){
this.widget_manager = options.widget_manager;
this.comm_manager = options.widget_manager.comm_manager;
this.cell = options.cell;
+ this.child_views = [];
},
update: function(){
@@ -187,6 +189,7 @@ function(widget_manager, underscore, backbone){
child_view: function(comm_id, view_name) {
var child_model = this.comm_manager.comms[comm_id].model;
var child_view = this.widget_manager.create_view(child_model, view_name, this.cell);
+ this.child_views.push(child_view);
return child_view;
},