s/target_name/widget_class

pull/37/head
Jonathan Frederic 11 years ago
parent cb2c76999c
commit db10ae8f2d

@ -193,7 +193,7 @@ define([
WidgetManager.prototype.create_model = function (options) {
// Create and return a new widget model.
//
// Minimally, one must provide the model_name and target_name
// Minimally, one must provide the model_name and widget_class
// parameters to create a model from Javascript.
//
// Example
@ -201,7 +201,7 @@ define([
// JS:
// window.slider = IPython.notebook.kernel.widget_manager.create_model({
// model_name: 'WidgetModel',
// target_name: 'IPython.html.widgets.widget_int.IntSlider',
// widget_class: 'IPython.html.widgets.widget_int.IntSlider',
// init_state_callback: function(model) { console.log('Create success!', model); }});
//
// Parameters
@ -210,7 +210,7 @@ define([
// Dictionary of options with the following contents:
// model_name: string
// Target name of the widget model to create.
// target_name: (optional) string
// widget_class: (optional) string
// Target name of the widget in the back-end.
// comm: (optional) Comm
// init_state_callback: (optional) callback
@ -221,7 +221,7 @@ define([
// Create a comm if it wasn't provided.
var comm = options.comm;
if (!comm) {
comm = this.comm_manager.new_comm('ipython.widget', {'target_name': options.target_name});
comm = this.comm_manager.new_comm('ipython.widget', {'widget_class': options.widget_class});
}
// Create and return a new model that is connected to the comm.

@ -99,8 +99,7 @@ class Widget(LoggingConfigurable):
@staticmethod
def handle_comm_opened(comm, msg):
"""Static method, called when a widget is constructed."""
target_name = msg['content']['data']['target_name']
widget_class = import_item(target_name)
widget_class = import_item(msg['content']['data']['widget_class'])
widget = widget_class(comm=comm)

Loading…
Cancel
Save