Show More
@@ -409,15 +409,15 b' define(["widgets/js/manager",' | |||||
409 | // Public constructor |
|
409 | // Public constructor | |
410 | DOMWidgetView.__super__.initialize.apply(this, arguments); |
|
410 | DOMWidgetView.__super__.initialize.apply(this, arguments); | |
411 | this.on('displayed', this.show, this); |
|
411 | this.on('displayed', this.show, this); | |
412 |
|
412 | this.after_displayed(function() { | ||
|
413 | this.update_visible(this.model, this.model.get("visible")); | |||
|
414 | this.update_css(this.model, this.model.get("_css")); | |||
|
415 | }, this); | |||
413 | this.model.on('msg:custom', this.on_msg, this); |
|
416 | this.model.on('msg:custom', this.on_msg, this); | |
414 | this.model.on('change:visible', this.update_visible, this); |
|
417 | this.model.on('change:visible', this.update_visible, this); | |
415 | this.model.on('change:_css', this.update_css, this); |
|
418 | this.model.on('change:_css', this.update_css, this); | |
416 |
|
||||
417 | this.update_visible(this.model, this.model.get("visible")); |
|
|||
418 | this.update_css(this.model, this.model.get("_css")); |
|
|||
419 | }, |
|
419 | }, | |
420 |
|
420 | |||
421 | on_msg: function(msg) { |
|
421 | on_msg: function(msg) { | |
422 | // Handle DOM specific msgs. |
|
422 | // Handle DOM specific msgs. | |
423 | switch(msg.msg_type) { |
|
423 | switch(msg.msg_type) { | |
@@ -434,19 +434,15 b' define(["widgets/js/manager",' | |||||
434 | // Add a DOM class to an element. |
|
434 | // Add a DOM class to an element. | |
435 | this._get_selector_element(selector).addClass(class_list); |
|
435 | this._get_selector_element(selector).addClass(class_list); | |
436 | }, |
|
436 | }, | |
437 |
|
437 | |||
438 | remove_class: function (selector, class_list) { |
|
438 | remove_class: function (selector, class_list) { | |
439 | // Remove a DOM class from an element. |
|
439 | // Remove a DOM class from an element. | |
440 | this._get_selector_element(selector).removeClass(class_list); |
|
440 | this._get_selector_element(selector).removeClass(class_list); | |
441 | }, |
|
441 | }, | |
442 |
|
442 | |||
443 | update_visible: function(model, value) { |
|
443 | update_visible: function(model, value) { | |
444 | // Update visibility |
|
444 | // Update visibility | |
445 | // The very first update seems to happen before the element is |
|
445 | this.$el.toggle(value); | |
446 | // finished rendering so we use setTimeout to give the element time |
|
|||
447 | // to render |
|
|||
448 | var e = this.$el; |
|
|||
449 | setTimeout(function() {e.toggle(value);},0); |
|
|||
450 | }, |
|
446 | }, | |
451 |
|
447 | |||
452 | update_css: function (model, css) { |
|
448 | update_css: function (model, css) { |
General Comments 0
You need to be logged in to leave comments.
Login now