##// END OF EJS Templates
Added on_create_widget callback to WidgetManager
Jonathan Frederic -
Show More
@@ -460,13 +460,30 b' define(["components/underscore/underscore-min",'
460 return IPython.notebook.get_msg_cell(msg_id);
460 return IPython.notebook.get_msg_cell(msg_id);
461 }
461 }
462 }
462 }
463
464
465 WidgetManager.prototype.on_create_widget = function (callback) {
466 this._create_widget_callback = callback;
467 }
468
469
470 WidgetManager.prototype._handle_create_widget = function (widget_model) {
471 if (this._create_widget_callback) {
472 try {
473 this._create_widget_callback(widget_model);
474 } catch (e) {
475 console.log("Exception in WidgetManager callback", e, widget_model);
476 }
477 }
478 }
463
479
464
480
465 WidgetManager.prototype._handle_com_open = function (comm, msg) {
481 WidgetManager.prototype._handle_com_open = function (comm, msg) {
466 var widget_type_name = msg.content.target_name;
482 var widget_type_name = msg.content.target_name;
467 var widget_model = new this.widget_model_types[widget_type_name](this.comm_manager, comm, this);
483 var widget_model = new this.widget_model_types[widget_type_name](this.comm_manager, comm, this);
484 this._handle_create_widget(widget_model);
468 }
485 }
469
486
470
487
471 //--------------------------------------------------------------------
488 //--------------------------------------------------------------------
472 // Init code
489 // Init code
General Comments 0
You need to be logged in to leave comments. Login now