diff --git a/IPython/html/static/widgets/js/manager.js b/IPython/html/static/widgets/js/manager.js
index 38626c8..114ca96 100644
--- a/IPython/html/static/widgets/js/manager.js
+++ b/IPython/html/static/widgets/js/manager.js
@@ -21,11 +21,8 @@ define([
this.comm_manager = comm_manager;
this._models = {}; /* Dictionary of model ids and model instances */
- // Register already-registered widget model types with the comm manager.
- var that = this;
- _.each(WidgetManager._model_types, function(model_type, model_name) {
- that.comm_manager.register_target(model_name, $.proxy(that._handle_comm_open, that));
- });
+ // Register with the comm manager.
+ this.comm_manager.register_target('ipython.widget', $.proxy(this._handle_comm_open, this));
};
//--------------------------------------------------------------------
@@ -38,14 +35,6 @@ define([
WidgetManager.register_widget_model = function (model_name, model_type) {
// Registers a widget model by name.
WidgetManager._model_types[model_name] = model_type;
-
- // Register the widget with the comm manager. Make sure to pass this object's context
- // in so `this` works in the call back.
- _.each(WidgetManager._managers, function(instance, i) {
- if (instance.comm_manager !== null) {
- instance.comm_manager.register_target(model_name, $.proxy(instance._handle_comm_open, instance));
- }
- });
};
WidgetManager.register_widget_view = function (view_name, view_type) {
@@ -186,7 +175,7 @@ define([
// Handle when a comm is opened.
var that = this;
var model_id = comm.comm_id;
- var widget_type_name = msg.content.target_name;
+ var widget_type_name = msg.content.data.model_name;
var widget_model = new WidgetManager._model_types[widget_type_name](this, model_id, comm);
widget_model.on('comm:close', function () {
delete that._models[model_id];
diff --git a/IPython/html/widgets/widget.py b/IPython/html/widgets/widget.py
index b8d9936..d81be3e 100644
--- a/IPython/html/widgets/widget.py
+++ b/IPython/html/widgets/widget.py
@@ -139,11 +139,12 @@ class Widget(LoggingConfigurable):
def open(self):
"""Open a comm to the frontend if one isn't already open."""
if self.comm is None:
- if self._model_id is None:
- self.comm = Comm(target_name=self._model_name)
- self._model_id = self.model_id
- else:
- self.comm = Comm(target_name=self._model_name, comm_id=self._model_id)
+ args = dict(target_name='ipython.widget', data={ 'model_name': self._model_name })
+ if self._model_id is not None:
+ args['comm_id'] = self._model_id
+ self.comm = Comm(**args)
+ self._model_id = self.model_id
+
self.comm.on_msg(self._handle_msg)
Widget.widgets[self.model_id] = self