Show More
@@ -7,7 +7,7 b' define([' | |||||
7 | "jquery", |
|
7 | "jquery", | |
8 | "base/js/namespace" |
|
8 | "base/js/namespace" | |
9 | ], function (_, Backbone, $, IPython) { |
|
9 | ], function (_, Backbone, $, IPython) { | |
10 |
|
10 | "use strict"; | ||
11 | //-------------------------------------------------------------------- |
|
11 | //-------------------------------------------------------------------- | |
12 | // WidgetManager class |
|
12 | // WidgetManager class | |
13 | //-------------------------------------------------------------------- |
|
13 | //-------------------------------------------------------------------- | |
@@ -93,37 +93,37 b' define([' | |||||
93 | }; |
|
93 | }; | |
94 |
|
94 | |||
95 |
|
95 | |||
96 |
WidgetManager.prototype.create_view = function(model, options |
|
96 | WidgetManager.prototype.create_view = function(model, options) { | |
97 | // Creates a view for a particular model. |
|
97 | // Creates a view for a particular model. | |
98 |
|
98 | |||
99 | var view_name = model.get('_view_name'); |
|
99 | var view_name = model.get('_view_name'); | |
100 | var view_mod = model.get('_view_module'); |
|
100 | var view_mod = model.get('_view_module'); | |
101 | errback = options.errback || function(err) {console.log(err)}; |
|
101 | var errback = options.errback || function(err) {console.log(err);}; | |
102 |
|
102 | |||
103 | var instantiate_view = function(ViewType) { |
|
103 | var instantiate_view = function(ViewType) { | |
104 | if (ViewType) { |
|
104 | if (ViewType) { | |
105 | // If a view is passed into the method, use that view's cell as |
|
105 | // If a view is passed into the method, use that view's cell as | |
106 | // the cell for the view that is created. |
|
106 | // the cell for the view that is created. | |
107 | options = options || {}; |
|
107 | options = options || {}; | |
108 |
if ( |
|
108 | if (options.parent !== undefined) { | |
109 |
options.cell = |
|
109 | options.cell = options.parent.options.cell; | |
110 | } |
|
110 | } | |
111 |
|
111 | |||
112 | // Create and render the view... |
|
112 | // Create and render the view... | |
113 | var parameters = {model: model, options: options}; |
|
113 | var parameters = {model: model, options: options}; | |
114 | view = new ViewType(parameters); |
|
114 | var view = new ViewType(parameters); | |
115 | view.render(); |
|
115 | view.render(); | |
116 | model.on('destroy', view.remove, view); |
|
116 | model.on('destroy', view.remove, view); | |
117 | options.callback(view); |
|
117 | options.callback(view); | |
118 | } else { |
|
118 | } else { | |
119 | errback({unknown_view: true, view_name: view_name, |
|
119 | errback({unknown_view: true, view_name: view_name, | |
120 | view_module: view_mod}) |
|
120 | view_module: view_mod}); | |
121 | } |
|
121 | } | |
122 | } |
|
122 | }; | |
123 |
|
123 | |||
124 | if (view_mod) { |
|
124 | if (view_mod) { | |
125 | require([view_mod], function(module) { |
|
125 | require([view_mod], function(module) { | |
126 | instantiate_view(module[view_name]) |
|
126 | instantiate_view(module[view_name]); | |
127 | }, errback); |
|
127 | }, errback); | |
128 | } else { |
|
128 | } else { | |
129 | instantiate_view(WidgetManager._view_types[view_name]); |
|
129 | instantiate_view(WidgetManager._view_types[view_name]); |
@@ -331,7 +331,7 b' define(["widgets/js/manager",' | |||||
331 | old_callback(child_view); |
|
331 | old_callback(child_view); | |
332 | }}, options || {}); |
|
332 | }}, options || {}); | |
333 |
|
333 | |||
334 |
this.model.widget_manager.create_view(child_model, options |
|
334 | this.model.widget_manager.create_view(child_model, options); | |
335 | }, |
|
335 | }, | |
336 |
|
336 | |||
337 | pop_child_view: function(child_model) { |
|
337 | pop_child_view: function(child_model) { |
General Comments 0
You need to be logged in to leave comments.
Login now