##// END OF EJS Templates
Fix bug where a child view could be displayed in a...
Jonathan Frederic -
Show More
@@ -35,7 +35,7 b' define(["components/underscore/underscore-min",'
35 this.pending_msgs = 0;
35 this.pending_msgs = 0;
36 this.msg_throttle = 3;
36 this.msg_throttle = 3;
37 this.msg_buffer = null;
37 this.msg_buffer = null;
38 this.views = {};
38 this.views = [];
39 this._custom_msg_callbacks = [];
39 this._custom_msg_callbacks = [];
40
40
41 // Remember comm associated with the model.
41 // Remember comm associated with the model.
@@ -54,15 +54,12 b' define(["components/underscore/underscore-min",'
54 this.last_modified_view = caller;
54 this.last_modified_view = caller;
55 this.save(this.changedAttributes(), {patch: true});
55 this.save(this.changedAttributes(), {patch: true});
56
56
57 for (var cell in this.views) {
57 for (var view_index in this.views) {
58 var views = this.views[cell];
58 var view = this.views[view_index];
59 for (var view_index in views) {
60 var view = views[view_index];
61 if (view !== caller) {
59 if (view !== caller) {
62 view.update();
60 view.update();
63 }
61 }
64 }
62 }
65 }
66 },
63 },
67
64
68
65
@@ -290,10 +287,8 b' define(["components/underscore/underscore-min",'
290 args = [].splice.call(arguments,1);
287 args = [].splice.call(arguments,1);
291 }
288 }
292
289
293 for (var cell in this.views) {
290 for (var view_index in this.views) {
294 var views = this.views[cell];
291 var view = this.views[view_index];
295 for (var view_index in views) {
296 var view = views[view_index];
297 var method = view[method_name];
292 var method = view[method_name];
298 if (args === null) {
293 if (args === null) {
299 method.apply(view);
294 method.apply(view);
@@ -301,7 +296,6 b' define(["components/underscore/underscore-min",'
301 method.apply(view, args);
296 method.apply(view, args);
302 }
297 }
303 }
298 }
304 }
305 },
299 },
306
300
307
301
@@ -314,9 +308,10 b' define(["components/underscore/underscore-min",'
314 if (parent_comm_id != undefined) {
308 if (parent_comm_id != undefined) {
315 var parent_comm = this.comm_manager.comms[parent_comm_id];
309 var parent_comm = this.comm_manager.comms[parent_comm_id];
316 var parent_model = parent_comm.model;
310 var parent_model = parent_comm.model;
317 var parent_views = parent_model.views[cell];
311 var parent_views = parent_model.views;
318 for (var parent_view_index in parent_views) {
312 for (var parent_view_index in parent_views) {
319 var parent_view = parent_views[parent_view_index];
313 var parent_view = parent_views[parent_view_index];
314 if (parent_view.cell === cell) {
320 if (parent_view.display_child != undefined) {
315 if (parent_view.display_child != undefined) {
321 var view = this._create_view(view_name, cell);
316 var view = this._create_view(view_name, cell);
322 if (view != null) {
317 if (view != null) {
@@ -328,6 +323,7 b' define(["components/underscore/underscore-min",'
328 }
323 }
329 }
324 }
330 }
325 }
326 }
331
327
332 // If no parent view is defined or exists. Add the view's
328 // If no parent view is defined or exists. Add the view's
333 // element to cell's widget div.
329 // element to cell's widget div.
@@ -358,23 +354,17 b' define(["components/underscore/underscore-min",'
358 if (view_type != undefined && view_type != null) {
354 if (view_type != undefined && view_type != null) {
359 var view = new view_type({model: this});
355 var view = new view_type({model: this});
360 view.render();
356 view.render();
361 if (this.views[cell]==undefined) {
357 this.views.push(view);
362 this.views[cell] = []
363 }
364 this.views[cell].push(view);
365 view.cell = cell;
358 view.cell = cell;
366
359
367 // Handle when the view element is remove from the page.
360 // Handle when the view element is remove from the page.
368 var that = this;
361 var that = this;
369 view.$el.on("remove", function(){
362 view.$el.on("remove", function(){
370 var index = that.views[cell].indexOf(view);
363 var index = that.views.indexOf(view);
371 if (index > -1) {
364 if (index > -1) {
372 that.views[cell].splice(index, 1);
365 that.views.splice(index, 1);
373 }
366 }
374 view.remove(); // Clean-up view
367 view.remove(); // Clean-up view
375 if (that.views[cell].length()==0) {
376 delete that.views[cell];
377 }
378
368
379 // Close the comm if there are no views left.
369 // Close the comm if there are no views left.
380 if (that.views.length()==0) {
370 if (that.views.length()==0) {
General Comments 0
You need to be logged in to leave comments. Login now