Show More
@@ -95,6 +95,11 b' define([' | |||
|
95 | 95 | |
|
96 | 96 | WidgetManager.prototype.create_view = function(model, options, view) { |
|
97 | 97 | // Creates a view for a particular model. |
|
98 | ||
|
99 | var view_name = model.get('_view_name'); | |
|
100 | var view_mod = model.get('_view_module'); | |
|
101 | errback = options.errback || function(err) {console.log(err)}; | |
|
102 | ||
|
98 | 103 | var instantiate_view = function(ViewType) { |
|
99 | 104 | if (ViewType) { |
|
100 | 105 | // If a view is passed into the method, use that view's cell as |
@@ -110,15 +115,16 b' define([' | |||
|
110 | 115 | view.render(); |
|
111 | 116 | model.on('destroy', view.remove, view); |
|
112 | 117 | options.callback(view); |
|
118 | } else { | |
|
119 | errback({unknown_view: true, view_name: view_name, | |
|
120 | view_module: view_mod}) | |
|
113 | 121 | } |
|
114 | 122 | } |
|
115 | ||
|
116 | var view_name = model.get('_view_name'); | |
|
117 | var view_mod = model.get('_view_module'); | |
|
123 | ||
|
118 | 124 | if (view_mod) { |
|
119 | 125 | require([view_mod], function(module) { |
|
120 | 126 | instantiate_view(module[view_name]) |
|
121 | }); | |
|
127 | }, errback); | |
|
122 | 128 | } else { |
|
123 | 129 | instantiate_view(WidgetManager._view_types[view_name]); |
|
124 | 130 | } |
@@ -308,7 +308,7 b' define(["widgets/js/manager",' | |||
|
308 | 308 | // Update view to be consistent with this.model |
|
309 | 309 | }, |
|
310 | 310 | |
|
311 |
create_child_view: function(child_model, |
|
|
311 | create_child_view: function(child_model, options) { | |
|
312 | 312 | // Create and return a child view. |
|
313 | 313 | // |
|
314 | 314 | // -given a model and (optionally) a view name if the view name is |
@@ -318,6 +318,7 b' define(["widgets/js/manager",' | |||
|
318 | 318 | // it would be great to have the widget manager add the cell metadata |
|
319 | 319 | // to the subview without having to add it here. |
|
320 | 320 | var that = this; |
|
321 | var old_callback = options.callback || function(view) {}; | |
|
321 | 322 | options = $.extend({ parent: this, callback: function(child_view) { |
|
322 | 323 | // Associate the view id with the model id. |
|
323 | 324 | if (that.child_model_views[child_model.id] === undefined) { |
@@ -327,7 +328,7 b' define(["widgets/js/manager",' | |||
|
327 | 328 | |
|
328 | 329 | // Remember the view by id. |
|
329 | 330 | that.child_views[child_view.id] = child_view; |
|
330 | callback(child_view); | |
|
331 | old_callback(child_view); | |
|
331 | 332 | }}, options || {}); |
|
332 | 333 | |
|
333 | 334 | this.model.widget_manager.create_view(child_model, options, this); |
@@ -75,14 +75,14 b' define([' | |||
|
75 | 75 | add_child_model: function(model) { |
|
76 | 76 | // Called when a model is added to the children list. |
|
77 | 77 | var that = this; |
|
78 | this.create_child_view(model, function(view) { | |
|
78 | this.create_child_view(model, {callback: function(view) { | |
|
79 | 79 | that.$box.append(view.$el); |
|
80 | 80 | |
|
81 | 81 | // Trigger the displayed event of the child view. |
|
82 | 82 | that.after_displayed(function() { |
|
83 | 83 | view.trigger('displayed'); |
|
84 | 84 | }); |
|
85 | }); | |
|
85 | }}); | |
|
86 | 86 | }, |
|
87 | 87 | }); |
|
88 | 88 |
@@ -114,7 +114,7 b' define([' | |||
|
114 | 114 | accordion_group.container_index = container_index; |
|
115 | 115 | this.model_containers[model.id] = accordion_group; |
|
116 | 116 | |
|
117 | this.create_child_view(model, function(view) { | |
|
117 | this.create_child_view(model, {callback: function(view) { | |
|
118 | 118 | accordion_inner.append(view.$el); |
|
119 | 119 | |
|
120 | 120 | that.update(); |
@@ -124,7 +124,7 b' define([' | |||
|
124 | 124 | that.after_displayed(function() { |
|
125 | 125 | view.trigger('displayed'); |
|
126 | 126 | }); |
|
127 | }); | |
|
127 | }}); | |
|
128 | 128 | }, |
|
129 | 129 | }); |
|
130 | 130 | |
@@ -186,7 +186,7 b' define([' | |||
|
186 | 186 | .css('list-style-type', 'none') |
|
187 | 187 | .appendTo(this.$tabs); |
|
188 | 188 | |
|
189 | this.create_child_view(model, function(view) { | |
|
189 | this.create_child_view(model, {callback: function(view) { | |
|
190 | 190 | view.parent_tab = tab; |
|
191 | 191 | |
|
192 | 192 | var tab_text = $('<a />') |
@@ -215,7 +215,7 b' define([' | |||
|
215 | 215 | that.after_displayed(function() { |
|
216 | 216 | view.trigger('displayed'); |
|
217 | 217 | }); |
|
218 | }); | |
|
218 | }}); | |
|
219 | 219 | }, |
|
220 | 220 | |
|
221 | 221 | update: function(options) { |
General Comments 0
You need to be logged in to leave comments.
Login now