Show More
@@ -81,6 +81,12 define(["notebook/js/widgets/base"], function(widget_manager) { | |||||
81 |
|
81 | |||
82 | render: function(){ |
|
82 | render: function(){ | |
83 | var that = this; |
|
83 | var that = this; | |
|
84 | this.children={}; | |||
|
85 | this.update_children([], this.model.get('children')); | |||
|
86 | this.model.on('change:children', function(model, value, options) { | |||
|
87 | this.update_children(model.previous('children'), value); | |||
|
88 | }, this); | |||
|
89 | ||||
84 | this.$el |
|
90 | this.$el | |
85 | .html('') |
|
91 | .html('') | |
86 | .on("remove", function(){ |
|
92 | .on("remove", function(){ | |
@@ -210,6 +216,14 define(["notebook/js/widgets/base"], function(widget_manager) { | |||||
210 | this.$window.css('z-index', max_zindex); |
|
216 | this.$window.css('z-index', max_zindex); | |
211 | }, |
|
217 | }, | |
212 |
|
218 | |||
|
219 | update_children: function(old_list, new_list) { | |||
|
220 | this.$el.empty(); | |||
|
221 | this.update_child_views(old_list, new_list); | |||
|
222 | _.each(new_list, function(element, index, list) { | |||
|
223 | this.$body.append(this.child_views[element].$el); | |||
|
224 | }, this) | |||
|
225 | }, | |||
|
226 | ||||
213 | update: function(){ |
|
227 | update: function(){ | |
214 | set_flex_properties(this, this.$body); |
|
228 | set_flex_properties(this, this.$body); | |
215 |
|
229 |
@@ -28,8 +28,8 define(["notebook/js/widgets/base"], function(widget_manager){ | |||||
28 | this.containers = []; |
|
28 | this.containers = []; | |
29 | this.update_children([], this.model.get('children')); |
|
29 | this.update_children([], this.model.get('children')); | |
30 | this.model.on('change:children', function(model, value, options) { |
|
30 | this.model.on('change:children', function(model, value, options) { | |
31 |
|
|
31 | this.update_children(model.previous('children'), value); | |
32 |
|
|
32 | }, this); | |
33 | }, |
|
33 | }, | |
34 |
|
34 | |||
35 | update_children: function(old_list, new_list) { |
|
35 | update_children: function(old_list, new_list) { | |
@@ -119,10 +119,10 define(["notebook/js/widgets/base"], function(widget_manager){ | |||||
119 |
|
119 | |||
120 | var TabView = IPython.WidgetView.extend({ |
|
120 | var TabView = IPython.WidgetView.extend({ | |
121 |
|
121 | |||
122 | initialize: function() { |
|
122 | initialize: function() { | |
123 | this.containers = []; |
|
123 | this.containers = []; | |
124 | IPython.WidgetView.prototype.initialize.apply(this, arguments); |
|
124 | IPython.WidgetView.prototype.initialize.apply(this, arguments); | |
125 | }, |
|
125 | }, | |
126 |
|
126 | |||
127 | render: function(){ |
|
127 | render: function(){ | |
128 | var uuid = 'tabs'+IPython.utils.uuid(); |
|
128 | var uuid = 'tabs'+IPython.utils.uuid(); | |
@@ -134,11 +134,22 define(["notebook/js/widgets/base"], function(widget_manager){ | |||||
134 | this.$tab_contents = $('<div />', {id: uuid + 'Content'}) |
|
134 | this.$tab_contents = $('<div />', {id: uuid + 'Content'}) | |
135 | .addClass('tab-content') |
|
135 | .addClass('tab-content') | |
136 | .appendTo(this.$el); |
|
136 | .appendTo(this.$el); | |
137 | var children = this.model.get('children'); |
|
137 | this.containers = []; | |
138 | for (var i in children) { |
|
138 | this.update_children([], this.model.get('children')); | |
139 | this.add_child_view(this.child_view(children[i])) |
|
139 | this.model.on('change:children', function(model, value, options) { | |
140 | } |
|
140 | this.update_children(model.previous('children'), value); | |
141 |
this |
|
141 | }, this); | |
|
142 | }, | |||
|
143 | ||||
|
144 | update_children: function(old_list, new_list) { | |||
|
145 | _.each(this.containers, function(element, index, list) { | |||
|
146 | element.remove(); | |||
|
147 | }, this); | |||
|
148 | this.containers = []; | |||
|
149 | this.update_child_views(old_list, new_list); | |||
|
150 | _.each(new_list, function(element, index, list) { | |||
|
151 | this.add_child_view(this.child_views[element]); | |||
|
152 | }, this) | |||
142 | }, |
|
153 | }, | |
143 |
|
154 | |||
144 | update: function() { |
|
155 | update: function() { |
General Comments 0
You need to be logged in to leave comments.
Login now