diff --git a/IPython/html/static/notebook/js/widgets/multicontainer.js b/IPython/html/static/notebook/js/widgets/multicontainer.js index 26145d4..2f2025b 100644 --- a/IPython/html/static/notebook/js/widgets/multicontainer.js +++ b/IPython/html/static/notebook/js/widgets/multicontainer.js @@ -14,10 +14,14 @@ require(["notebook/js/widget"], function(){ // Set tab titles var titles = this.model.get('_titles'); for (var page_index in titles) { - var accordian_toggle = this.containers[page_index] - .find('.accordion-heading') - .find('.accordion-toggle'); - accordian_toggle.html(titles[page_index]); + + var accordian = this.containers[page_index] + if (accordian != undefined) { + accordian + .find('.accordion-heading') + .find('.accordion-toggle') + .html(titles[page_index]); + } } return IPython.WidgetView.prototype.update.call(this); @@ -49,6 +53,7 @@ require(["notebook/js/widget"], function(){ this.containers.push(accordion_group); accordion_inner.append(view.$el); + this.update(); }, }); diff --git a/IPython/html/widgets/widget.py b/IPython/html/widgets/widget.py index 33ad1ee..ab28735 100644 --- a/IPython/html/widgets/widget.py +++ b/IPython/html/widgets/widget.py @@ -160,21 +160,22 @@ class Widget(LoggingConfigurable): key : unicode (optional) A single property's name to sync with the frontend. """ - state = {} - - # If a key is provided, just send the state of that key. - keys = [] - if key is None: - keys.extend(self.keys) - else: - keys.append(key) - for key in self.keys: - try: - state[key] = getattr(self, key) - except Exception as e: - pass # Eat errors, nom nom nom - self.comm.send({"method": "update", - "state": state}) + if self.comm is not None: + state = {} + + # If a key is provided, just send the state of that key. + keys = [] + if key is None: + keys.extend(self.keys) + else: + keys.append(key) + for key in self.keys: + try: + state[key] = getattr(self, key) + except Exception as e: + pass # Eat errors, nom nom nom + self.comm.send({"method": "update", + "state": state}) def get_css(self, key, selector=""):