mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-05 12:19:58 +08:00
Fix visible attribute for the very first render
This commit is contained in:
parent
9b1a0d70a2
commit
7810c78aea
@ -244,12 +244,11 @@ function(widget_manager, underscore, backbone){
|
|||||||
|
|
||||||
var WidgetView = BaseWidgetView.extend({
|
var WidgetView = BaseWidgetView.extend({
|
||||||
initialize: function (options) {
|
initialize: function (options) {
|
||||||
this.model.on('change:visible', function() {this.$el.toggle(this.model.get('visible'))}, this);
|
// TODO: make changes more granular
|
||||||
this.model.on('change', this.update_css, this);
|
this.model.on('change', this.update, this);
|
||||||
BaseWidgetView.prototype.initialize.apply(this, arguments);
|
BaseWidgetView.prototype.initialize.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
add_class: function (selector, class_list) {
|
add_class: function (selector, class_list) {
|
||||||
var elements = this._get_selector_element(selector);
|
var elements = this._get_selector_element(selector);
|
||||||
if (elements.length > 0) {
|
if (elements.length > 0) {
|
||||||
@ -264,8 +263,14 @@ function(widget_manager, underscore, backbone){
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
update_css: function () {
|
update: function () {
|
||||||
var css = this.model.css;
|
// the very first update seems to happen before the element is finished rendering
|
||||||
|
// so we use setTimeout to give the element time to render
|
||||||
|
var e = this.$el;
|
||||||
|
var visible = this.model.get('visible');
|
||||||
|
setTimeout(function() {e.toggle(visible)},0);
|
||||||
|
|
||||||
|
var css = this.model.css;
|
||||||
if (css === undefined) {return;}
|
if (css === undefined) {return;}
|
||||||
for (var selector in css) {
|
for (var selector in css) {
|
||||||
if (css.hasOwnProperty(selector)) {
|
if (css.hasOwnProperty(selector)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user