Show More
@@ -212,9 +212,11 b' define(["components/underscore/underscore-min",' | |||
|
212 | 212 | var parent_view = parent_views[parent_view_index]; |
|
213 | 213 | if (parent_view.display_child != undefined) { |
|
214 | 214 | var view = this._create_view(view_name, cell); |
|
215 |
|
|
|
216 |
|
|
|
217 |
display |
|
|
215 | if (view != null) { | |
|
216 | new_views.push(view); | |
|
217 | parent_view.display_child(view); | |
|
218 | displayed = true; | |
|
219 | } | |
|
218 | 220 | } |
|
219 | 221 | } |
|
220 | 222 | } |
@@ -223,11 +225,13 b' define(["components/underscore/underscore-min",' | |||
|
223 | 225 | // No parent view is defined or exists. Add the view's |
|
224 | 226 | // element to cell's widget div. |
|
225 | 227 | var view = this._create_view(view_name, cell); |
|
226 |
|
|
|
228 | if (view != null) { | |
|
229 | new_views.push(view); | |
|
227 | 230 | |
|
228 | if (cell.widget_subarea != undefined && cell.widget_subarea != null) { | |
|
229 | cell.widget_area.show(); | |
|
230 | cell.widget_subarea.append(view.$el); | |
|
231 | if (cell.widget_subarea != undefined && cell.widget_subarea != null) { | |
|
232 | cell.widget_area.show(); | |
|
233 | cell.widget_subarea.append(view.$el); | |
|
234 | } | |
|
231 | 235 | } |
|
232 | 236 | } |
|
233 | 237 | |
@@ -240,32 +244,36 b' define(["components/underscore/underscore-min",' | |||
|
240 | 244 | |
|
241 | 245 | // Create a view |
|
242 | 246 | _create_view: function (view_name, cell) { |
|
243 |
var view = |
|
|
244 | view.render(); | |
|
245 | if (this.views[cell]==undefined) { | |
|
246 |
|
|
|
247 | } | |
|
248 |
this.views[cell] |
|
|
249 | view.cell = cell; | |
|
250 | ||
|
251 | // Handle when the view element is remove from the page. | |
|
252 | var that = this; | |
|
253 | view.$el.on("remove", function(){ | |
|
254 | var index = that.views[cell].indexOf(view); | |
|
255 | if (index > -1) { | |
|
256 | that.views[cell].splice(index, 1); | |
|
257 | } | |
|
258 | view.remove(); // Clean-up view | |
|
259 | if (that.views[cell].length()==0) { | |
|
260 | delete that.views[cell]; | |
|
247 | var view_type = this.widget_manager.widget_view_types[view_name]; | |
|
248 | if (view_type != undefined && view_type != null) { | |
|
249 | var view = new view_type({model: this}); | |
|
250 | view.render(); | |
|
251 | if (this.views[cell]==undefined) { | |
|
252 | this.views[cell] = [] | |
|
261 | 253 | } |
|
254 | this.views[cell].push(view); | |
|
255 | view.cell = cell; | |
|
262 | 256 | |
|
263 | // Close the comm if there are no views left. | |
|
264 | if (that.views.length()==0) { | |
|
265 | that.comm.close(); | |
|
266 | } | |
|
267 | }); | |
|
268 | return view; | |
|
257 | // Handle when the view element is remove from the page. | |
|
258 | var that = this; | |
|
259 | view.$el.on("remove", function(){ | |
|
260 | var index = that.views[cell].indexOf(view); | |
|
261 | if (index > -1) { | |
|
262 | that.views[cell].splice(index, 1); | |
|
263 | } | |
|
264 | view.remove(); // Clean-up view | |
|
265 | if (that.views[cell].length()==0) { | |
|
266 | delete that.views[cell]; | |
|
267 | } | |
|
268 | ||
|
269 | // Close the comm if there are no views left. | |
|
270 | if (that.views.length()==0) { | |
|
271 | that.comm.close(); | |
|
272 | } | |
|
273 | }); | |
|
274 | return view; | |
|
275 | } | |
|
276 | return null; | |
|
269 | 277 | }, |
|
270 | 278 | |
|
271 | 279 |
General Comments 0
You need to be logged in to leave comments.
Login now