##// END OF EJS Templates
Merge pull request #6548 from SylvainCorlay/widget_views_by_id...
Jonathan Frederic -
r18036:e9b674db merge
parent child Browse files
Show More
@@ -26,7 +26,7 b' define(["widgets/js/manager",'
26 this.msg_buffer = null;
26 this.msg_buffer = null;
27 this.state_lock = null;
27 this.state_lock = null;
28 this.id = model_id;
28 this.id = model_id;
29 this.views = [];
29 this.views = {};
30
30
31 if (comm !== undefined) {
31 if (comm !== undefined) {
32 // Remember comm associated with the model.
32 // Remember comm associated with the model.
@@ -57,9 +57,11 b' define(["widgets/js/manager",'
57 delete this.comm.model; // Delete ref so GC will collect widget model.
57 delete this.comm.model; // Delete ref so GC will collect widget model.
58 delete this.comm;
58 delete this.comm;
59 delete this.model_id; // Delete id from model so widget manager cleans up.
59 delete this.model_id; // Delete id from model so widget manager cleans up.
60 _.each(this.views, function(view, i) {
60 for (var id in this.views) {
61 view.remove();
61 if (this.views.hasOwnProperty(id)) {
62 });
62 this.views[id].remove();
63 }
64 }
63 },
65 },
64
66
65 _handle_comm_msg: function (msg) {
67 _handle_comm_msg: function (msg) {
@@ -293,8 +295,8 b' define(["widgets/js/manager",'
293 this.options = parameters.options;
295 this.options = parameters.options;
294 this.child_model_views = {};
296 this.child_model_views = {};
295 this.child_views = {};
297 this.child_views = {};
296 this.model.views.push(this);
297 this.id = this.id || IPython.utils.uuid();
298 this.id = this.id || IPython.utils.uuid();
299 this.model.views[this.id] = this;
298 this.on('displayed', function() {
300 this.on('displayed', function() {
299 this.is_displayed = true;
301 this.is_displayed = true;
300 }, this);
302 }, this);
@@ -339,7 +341,7 b' define(["widgets/js/manager",'
339 var view = this.child_views[view_id];
341 var view = this.child_views[view_id];
340 delete this.child_views[view_id];
342 delete this.child_views[view_id];
341 view_ids.splice(0,1);
343 view_ids.splice(0,1);
342 child_model.views.pop(view);
344 delete child_model.views[view_id];
343
345
344 // Remove the view list specific to this model if it is empty.
346 // Remove the view list specific to this model if it is empty.
345 if (view_ids.length === 0) {
347 if (view_ids.length === 0) {
General Comments 0
You need to be logged in to leave comments. Login now