diff --git a/IPython/html/static/widgets/js/widget.js b/IPython/html/static/widgets/js/widget.js index fb3a404..0a4caa7 100644 --- a/IPython/html/static/widgets/js/widget.js +++ b/IPython/html/static/widgets/js/widget.js @@ -76,7 +76,7 @@ define(["widgets/js/manager", this.set_state(msg.content.data.state); if (this.init_state_callback) { this.init_state_callback.apply(this, [this]); - this.init_state_callback = null; + delete this.init_state_callback; } break; case 'custom': diff --git a/IPython/html/widgets/widget.py b/IPython/html/widgets/widget.py index e4c189d..f16b94d 100644 --- a/IPython/html/widgets/widget.py +++ b/IPython/html/widgets/widget.py @@ -102,7 +102,7 @@ class Widget(LoggingConfigurable): target_name = msg['content']['data']['target_name'] widget_class = import_item(target_name) widget = widget_class(open_comm=False) - widget.set_comm(comm) + widget.comm = comm #------------------------------------------------------------------------- @@ -160,11 +160,11 @@ class Widget(LoggingConfigurable): 'model_module': self._model_module}) if self._model_id is not None: args['comm_id'] = self._model_id - self.set_comm(Comm(**args)) + self.comm = Comm(**args) - def set_comm(self, comm): - """Set's the comm of the widget.""" - self.comm = comm + def _comm_changed(self, name, new): + """Called when the comm is changed.""" + self.comm = new self._model_id = self.model_id self.comm.on_msg(self._handle_msg) @@ -173,7 +173,6 @@ class Widget(LoggingConfigurable): # first update self.send_state() - @property def model_id(self): """Gets the model id of this widget.