##// END OF EJS Templates
Fix visible attribute for the very first render
Jason Grout -
Show More
@@ -244,12 +244,11 function(widget_manager, underscore, backbone){
244 244
245 245 var WidgetView = BaseWidgetView.extend({
246 246 initialize: function (options) {
247 this.model.on('change:visible', function() {this.$el.toggle(this.model.get('visible'))}, this);
248 this.model.on('change', this.update_css, this);
247 // TODO: make changes more granular
248 this.model.on('change', this.update, this);
249 249 BaseWidgetView.prototype.initialize.apply(this, arguments);
250 250 },
251 251
252
253 252 add_class: function (selector, class_list) {
254 253 var elements = this._get_selector_element(selector);
255 254 if (elements.length > 0) {
@@ -264,8 +263,14 function(widget_manager, underscore, backbone){
264 263 }
265 264 },
266 265
267 update_css: function () {
268 var css = this.model.css;
266 update: function () {
267 // the very first update seems to happen before the element is finished rendering
268 // so we use setTimeout to give the element time to render
269 var e = this.$el;
270 var visible = this.model.get('visible');
271 setTimeout(function() {e.toggle(visible)},0);
272
273 var css = this.model.css;
269 274 if (css === undefined) {return;}
270 275 for (var selector in css) {
271 276 if (css.hasOwnProperty(selector)) {
General Comments 0
You need to be logged in to leave comments. Login now