##// END OF EJS Templates
Store views in the models and store child views in the views
Jason Grout -
Show More
@@ -98,8 +98,7 b''
98 if (ViewType !== undefined && ViewType !== null) {
98 if (ViewType !== undefined && ViewType !== null) {
99 var view = new ViewType({model: model, widget_manager: this, cell: cell});
99 var view = new ViewType({model: model, widget_manager: this, cell: cell});
100 view.render();
100 view.render();
101 //this.views.push(view);
101 model.views.push(view);
102
103 /*
102 /*
104 // jng: Handle when the view element is remove from the page.
103 // jng: Handle when the view element is remove from the page.
105 // observe the view destruction event and do this. We may need
104 // observe the view destruction event and do this. We may need
@@ -29,6 +29,7 b' function(widget_manager, underscore, backbone){'
29 this.msg_throttle = 3;
29 this.msg_throttle = 3;
30 this.msg_buffer = null;
30 this.msg_buffer = null;
31 this.id = widget_id;
31 this.id = widget_id;
32 this.views = [];
32
33
33 if (comm !== undefined) {
34 if (comm !== undefined) {
34 // Remember comm associated with the model.
35 // Remember comm associated with the model.
@@ -43,7 +44,6 b' function(widget_manager, underscore, backbone){'
43
44
44 return Backbone.Model.apply(this);
45 return Backbone.Model.apply(this);
45 },
46 },
46
47
47
48 send: function (content, callbacks) {
48 send: function (content, callbacks) {
49 if (this.comm !== undefined) {
49 if (this.comm !== undefined) {
@@ -55,6 +55,7 b' function(widget_manager, underscore, backbone){'
55 // Handle when a widget is closed.
55 // Handle when a widget is closed.
56 _handle_comm_closed: function (msg) {
56 _handle_comm_closed: function (msg) {
57 // jng: widget manager should observe the comm_close event and delete views when triggered
57 // jng: widget manager should observe the comm_close event and delete views when triggered
58
58 this.trigger('comm:close');
59 this.trigger('comm:close');
59 delete this.comm.model; // Delete ref so GC will collect widget model.
60 delete this.comm.model; // Delete ref so GC will collect widget model.
60 delete this.comm;
61 delete this.comm;
@@ -178,6 +179,7 b' function(widget_manager, underscore, backbone){'
178 this.widget_manager = options.widget_manager;
179 this.widget_manager = options.widget_manager;
179 this.comm_manager = options.widget_manager.comm_manager;
180 this.comm_manager = options.widget_manager.comm_manager;
180 this.cell = options.cell;
181 this.cell = options.cell;
182 this.child_views = [];
181 },
183 },
182
184
183 update: function(){
185 update: function(){
@@ -187,6 +189,7 b' function(widget_manager, underscore, backbone){'
187 child_view: function(comm_id, view_name) {
189 child_view: function(comm_id, view_name) {
188 var child_model = this.comm_manager.comms[comm_id].model;
190 var child_model = this.comm_manager.comms[comm_id].model;
189 var child_view = this.widget_manager.create_view(child_model, view_name, this.cell);
191 var child_view = this.widget_manager.create_view(child_model, view_name, this.cell);
192 this.child_views.push(child_view);
190 return child_view;
193 return child_view;
191 },
194 },
192
195
General Comments 0
You need to be logged in to leave comments. Login now