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,13 +54,10 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 |
|
57 | for (var view_index in this.views) { | |
58 |
var view |
|
58 | var view = this.views[view_index]; | |
59 |
f |
|
59 | if (view !== caller) { | |
60 | var view = views[view_index]; |
|
60 | view.update(); | |
61 | if (view !== caller) { |
|
|||
62 | view.update(); |
|
|||
63 | } |
|
|||
64 | } |
|
61 | } | |
65 | } |
|
62 | } | |
66 | }, |
|
63 | }, | |
@@ -290,16 +287,13 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 |
|
290 | for (var view_index in this.views) { | |
294 |
var view |
|
291 | var view = this.views[view_index]; | |
295 | for (var view_index in views) { |
|
292 | var method = view[method_name]; | |
296 | var view = views[view_index]; |
|
293 | if (args === null) { | |
297 |
|
|
294 | method.apply(view); | |
298 |
|
|
295 | } else { | |
299 |
|
|
296 | method.apply(view, args); | |
300 | } else { |
|
|||
301 | method.apply(view, args); |
|
|||
302 | } |
|
|||
303 | } |
|
297 | } | |
304 | } |
|
298 | } | |
305 | }, |
|
299 | }, | |
@@ -314,17 +308,19 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 |
|
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]; | |
320 |
if (parent_view. |
|
314 | if (parent_view.cell === cell) { | |
321 | var view = this._create_view(view_name, cell); |
|
315 | if (parent_view.display_child != undefined) { | |
322 | if (view != null) { |
|
316 | var view = this._create_view(view_name, cell); | |
323 |
|
|
317 | if (view != null) { | |
324 |
|
|
318 | new_views.push(view); | |
325 |
display |
|
319 | parent_view.display_child(view); | |
326 |
|
|
320 | displayed = true; | |
327 | } |
|
321 | this._handle_view_displayed(view); | |
|
322 | } | |||
|
323 | } | |||
328 | } |
|
324 | } | |
329 | } |
|
325 | } | |
330 | } |
|
326 | } | |
@@ -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 |
|
|
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 |
|
363 | var index = that.views.indexOf(view); | |
371 | if (index > -1) { |
|
364 | if (index > -1) { | |
372 |
that.views |
|
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