mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-13 13:17:50 +08:00
Added update_children
pattern to remaining parent widgets
This commit is contained in:
parent
2211abd28d
commit
8732761524
@ -81,6 +81,12 @@ define(["notebook/js/widgets/base"], function(widget_manager) {
|
||||
|
||||
render: function(){
|
||||
var that = this;
|
||||
this.children={};
|
||||
this.update_children([], this.model.get('children'));
|
||||
this.model.on('change:children', function(model, value, options) {
|
||||
this.update_children(model.previous('children'), value);
|
||||
}, this);
|
||||
|
||||
this.$el
|
||||
.html('')
|
||||
.on("remove", function(){
|
||||
@ -210,6 +216,14 @@ define(["notebook/js/widgets/base"], function(widget_manager) {
|
||||
this.$window.css('z-index', max_zindex);
|
||||
},
|
||||
|
||||
update_children: function(old_list, new_list) {
|
||||
this.$el.empty();
|
||||
this.update_child_views(old_list, new_list);
|
||||
_.each(new_list, function(element, index, list) {
|
||||
this.$body.append(this.child_views[element].$el);
|
||||
}, this)
|
||||
},
|
||||
|
||||
update: function(){
|
||||
set_flex_properties(this, this.$body);
|
||||
|
||||
|
@ -28,8 +28,8 @@ define(["notebook/js/widgets/base"], function(widget_manager){
|
||||
this.containers = [];
|
||||
this.update_children([], this.model.get('children'));
|
||||
this.model.on('change:children', function(model, value, options) {
|
||||
this.update_children(model.previous('children'), value);
|
||||
}, this);
|
||||
this.update_children(model.previous('children'), value);
|
||||
}, this);
|
||||
},
|
||||
|
||||
update_children: function(old_list, new_list) {
|
||||
@ -119,10 +119,10 @@ define(["notebook/js/widgets/base"], function(widget_manager){
|
||||
|
||||
var TabView = IPython.WidgetView.extend({
|
||||
|
||||
initialize: function() {
|
||||
this.containers = [];
|
||||
IPython.WidgetView.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
initialize: function() {
|
||||
this.containers = [];
|
||||
IPython.WidgetView.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
render: function(){
|
||||
var uuid = 'tabs'+IPython.utils.uuid();
|
||||
@ -134,11 +134,22 @@ define(["notebook/js/widgets/base"], function(widget_manager){
|
||||
this.$tab_contents = $('<div />', {id: uuid + 'Content'})
|
||||
.addClass('tab-content')
|
||||
.appendTo(this.$el);
|
||||
var children = this.model.get('children');
|
||||
for (var i in children) {
|
||||
this.add_child_view(this.child_view(children[i]))
|
||||
}
|
||||
this.update();
|
||||
this.containers = [];
|
||||
this.update_children([], this.model.get('children'));
|
||||
this.model.on('change:children', function(model, value, options) {
|
||||
this.update_children(model.previous('children'), value);
|
||||
}, this);
|
||||
},
|
||||
|
||||
update_children: function(old_list, new_list) {
|
||||
_.each(this.containers, function(element, index, list) {
|
||||
element.remove();
|
||||
}, this);
|
||||
this.containers = [];
|
||||
this.update_child_views(old_list, new_list);
|
||||
_.each(new_list, function(element, index, list) {
|
||||
this.add_child_view(this.child_views[element]);
|
||||
}, this)
|
||||
},
|
||||
|
||||
update: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user