Show More
@@ -321,18 +321,20 function(WidgetManager, _, Backbone){ | |||
|
321 | 321 | var view_ids = this.child_model_views[child_model.id]; |
|
322 | 322 | if (view_ids !== undefined) { |
|
323 | 323 | |
|
324 |
// |
|
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
|
329 |
|
|
|
330 | child_model.views.pop(view); | |
|
324 | // Only delete the first view in the list. | |
|
325 | var view_id = view_ids[0]; | |
|
326 | var view = this.child_views[view_id]; | |
|
327 | delete this.child_views[view_id]; | |
|
328 | delete view_ids[0]; | |
|
329 | child_model.views.pop(view); | |
|
330 | ||
|
331 | // Remove the view list specific to this model if it is empty. | |
|
332 | if (view_ids.length === 0) { | |
|
333 | delete this.child_model_views[child_model.id]; | |
|
331 | 334 | } |
|
332 | ||
|
333 | // Remove the view list specific to this model. | |
|
334 | delete this.child_model_views[child_model.id]; | |
|
335 | return view; | |
|
335 | 336 | } |
|
337 | return null; | |
|
336 | 338 | }, |
|
337 | 339 | |
|
338 | 340 | do_diff: function(old_list, new_list, removed_callback, added_callback) { |
@@ -22,9 +22,9 define(["widgets/js/widget"], function(WidgetManager) { | |||
|
22 | 22 | this.$el.addClass('widget-container') |
|
23 | 23 | .addClass('vbox'); |
|
24 | 24 | this.children={}; |
|
25 |
this.update_children([], this.model.get(' |
|
|
26 |
this.model.on('change: |
|
|
27 |
this.update_children(model.previous(' |
|
|
25 | this.update_children([], this.model.get('children')); | |
|
26 | this.model.on('change:children', function(model, value, options) { | |
|
27 | this.update_children(model.previous('children'), value); | |
|
28 | 28 | }, this); |
|
29 | 29 | this.update(); |
|
30 | 30 | |
@@ -51,8 +51,7 define(["widgets/js/widget"], function(WidgetManager) { | |||
|
51 | 51 | |
|
52 | 52 | remove_child_model: function(model) { |
|
53 | 53 | // Called when a model is removed from the children list. |
|
54 |
this.child_view |
|
|
55 | this.delete_child_view(model); | |
|
54 | this.delete_child_view(model).remove(); | |
|
56 | 55 | }, |
|
57 | 56 | |
|
58 | 57 | add_child_model: function(model) { |
@@ -187,9 +186,9 define(["widgets/js/widget"], function(WidgetManager) { | |||
|
187 | 186 | this._shown_once = false; |
|
188 | 187 | this.popped_out = true; |
|
189 | 188 | |
|
190 |
this.update_children([], this.model.get(' |
|
|
191 |
this.model.on('change: |
|
|
192 |
this.update_children(model.previous(' |
|
|
189 | this.update_children([], this.model.get('children')); | |
|
190 | this.model.on('change:children', function(model, value, options) { | |
|
191 | this.update_children(model.previous('children'), value); | |
|
193 | 192 | }, this); |
|
194 | 193 | this.update(); |
|
195 | 194 | |
@@ -257,8 +256,7 define(["widgets/js/widget"], function(WidgetManager) { | |||
|
257 | 256 | |
|
258 | 257 | remove_child_model: function(model) { |
|
259 | 258 | // Called when a child is removed from children list. |
|
260 |
this.child_view |
|
|
261 | this.delete_child_view(model); | |
|
259 | this.delete_child_view(model).remove(); | |
|
262 | 260 | }, |
|
263 | 261 | |
|
264 | 262 | add_child_model: function(model) { |
@@ -25,9 +25,9 define(["widgets/js/widget"], function(WidgetManager){ | |||
|
25 | 25 | .addClass('panel-group'); |
|
26 | 26 | this.containers = []; |
|
27 | 27 | this.model_containers = {}; |
|
28 |
this.update_children([], this.model.get(' |
|
|
29 |
this.model.on('change: |
|
|
30 |
this.update_children(model.previous(' |
|
|
28 | this.update_children([], this.model.get('children')); | |
|
29 | this.model.on('change:children', function(model, value, options) { | |
|
30 | this.update_children(model.previous('children'), value); | |
|
31 | 31 | }, this); |
|
32 | 32 | this.model.on('change:selected_index', function(model, value, options) { |
|
33 | 33 | this.update_selected_index(model.previous('selected_index'), value, options); |
@@ -163,9 +163,9 define(["widgets/js/widget"], function(WidgetManager){ | |||
|
163 | 163 | .addClass('tab-content') |
|
164 | 164 | .appendTo(this.$el); |
|
165 | 165 | this.containers = []; |
|
166 |
this.update_children([], this.model.get(' |
|
|
167 |
this.model.on('change: |
|
|
168 |
this.update_children(model.previous(' |
|
|
166 | this.update_children([], this.model.get('children')); | |
|
167 | this.model.on('change:children', function(model, value, options) { | |
|
168 | this.update_children(model.previous('children'), value); | |
|
169 | 169 | }, this); |
|
170 | 170 | |
|
171 | 171 | // Trigger model displayed events for any models that are child to |
@@ -190,12 +190,11 define(["widgets/js/widget"], function(WidgetManager){ | |||
|
190 | 190 | |
|
191 | 191 | remove_child_model: function(model) { |
|
192 | 192 | // Called when a child is removed from children list. |
|
193 |
var view = this.child_view |
|
|
193 | var view = this.delete_child_view(model); | |
|
194 | 194 | this.containers.splice(view.parent_tab.tab_text_index, 1); |
|
195 | 195 | view.parent_tab.remove(); |
|
196 | 196 | view.parent_container.remove(); |
|
197 | 197 | view.remove(); |
|
198 | this.delete_child_view(model); | |
|
199 | 198 | }, |
|
200 | 199 | |
|
201 | 200 | add_child_model: function(model) { |
@@ -15,16 +15,14 class ContainerWidget(DOMWidget): | |||
|
15 | 15 | # Child widgets in the container. |
|
16 | 16 | # Using a tuple here to force reassignment to update the list. |
|
17 | 17 | # When a proper notifying-list trait exists, that is what should be used here. |
|
18 | children = Tuple() | |
|
19 | _children = Tuple(sync=True) | |
|
20 | ||
|
18 | children = Tuple(sync=True) | |
|
21 | 19 | |
|
22 | 20 | def __init__(self, **kwargs): |
|
23 | 21 | super(ContainerWidget, self).__init__(**kwargs) |
|
24 | 22 | self.on_displayed(ContainerWidget._fire_children_displayed) |
|
25 | 23 | |
|
26 | 24 | def _fire_children_displayed(self): |
|
27 |
for child in self. |
|
|
25 | for child in self.children: | |
|
28 | 26 | child._handle_displayed() |
|
29 | 27 | |
|
30 | 28 |
General Comments 0
You need to be logged in to leave comments.
Login now