|
|
|
|
@ -190,7 +190,7 @@ define([
|
|
|
|
|
return this.create_model({model_name: msg.content.data.target_name, comm: comm});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
WidgetManager.prototype.create_model = function (model_name, target_name) {
|
|
|
|
|
WidgetManager.prototype.create_model = function (model_name, target_name, init_state_callback) {
|
|
|
|
|
// Create and return a new widget model.
|
|
|
|
|
//
|
|
|
|
|
// Parameters
|
|
|
|
|
@ -199,7 +199,13 @@ define([
|
|
|
|
|
// Target name of the widget model to create.
|
|
|
|
|
// target_name: string
|
|
|
|
|
// Target name of the widget in the back-end.
|
|
|
|
|
return this._create_model({model_name: model_name, target_name: target_name});
|
|
|
|
|
// init_state_callback: (optional) callback
|
|
|
|
|
// Called when the first state push from the back-end is
|
|
|
|
|
// recieved.
|
|
|
|
|
return this._create_model({
|
|
|
|
|
model_name: model_name,
|
|
|
|
|
target_name: target_name,
|
|
|
|
|
init_state_callback: init_state_callback});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
WidgetManager.prototype._create_model = function (options) {
|
|
|
|
|
@ -214,6 +220,9 @@ define([
|
|
|
|
|
// target_name: (optional) string
|
|
|
|
|
// Target name of the widget in the back-end.
|
|
|
|
|
// comm: (optional) Comm
|
|
|
|
|
// init_state_callback: (optional) callback
|
|
|
|
|
// Called when the first state push from the back-end is
|
|
|
|
|
// recieved.
|
|
|
|
|
|
|
|
|
|
// Create a comm if it wasn't provided.
|
|
|
|
|
var comm = options.comm;
|
|
|
|
|
@ -226,8 +235,8 @@ define([
|
|
|
|
|
|
|
|
|
|
var instantiate_model = function(ModelType) {
|
|
|
|
|
var model_id = comm.comm_id;
|
|
|
|
|
var widget_model = new ModelType(that, model_id, comm);
|
|
|
|
|
widget_model.on('comm:close', function () {sss
|
|
|
|
|
var widget_model = new ModelType(that, model_id, comm, options.init_state_callback);
|
|
|
|
|
widget_model.on('comm:close', function () {
|
|
|
|
|
delete that._models[model_id];
|
|
|
|
|
});
|
|
|
|
|
that._models[model_id] = widget_model;
|
|
|
|
|
|