Show More
@@ -292,8 +292,6 b' define(["widgets/js/manager",' | |||
|
292 | 292 | // Public constructor. |
|
293 | 293 | this.model.on('change',this.update,this); |
|
294 | 294 | this.options = parameters.options; |
|
295 | this.child_model_views = {}; | |
|
296 | this.child_views = {}; | |
|
297 | 295 | this.id = this.id || utils.uuid(); |
|
298 | 296 | this.model.views[this.id] = this; |
|
299 | 297 | this.on('displayed', function() { |
@@ -311,38 +309,7 b' define(["widgets/js/manager",' | |||
|
311 | 309 | // Create and promise that resolves to a child view of a given model |
|
312 | 310 | var that = this; |
|
313 | 311 | options = $.extend({ parent: this }, options || {}); |
|
314 |
return this.model.widget_manager.create_view(child_model, options).th |
|
|
315 | // Associate the view id with the model id. | |
|
316 | if (that.child_model_views[child_model.id] === undefined) { | |
|
317 | that.child_model_views[child_model.id] = []; | |
|
318 | } | |
|
319 | that.child_model_views[child_model.id].push(child_view.id); | |
|
320 | // Remember the view by id. | |
|
321 | that.child_views[child_view.id] = child_view; | |
|
322 | return child_view; | |
|
323 | }, utils.reject("Couldn't create child view")); | |
|
324 | }, | |
|
325 | ||
|
326 | pop_child_view: function(child_model) { | |
|
327 | // Delete a child view that was previously created using create_child_view. | |
|
328 | console.error("Deprecated pop_child_view; use a ViewList or similar class instead"); | |
|
329 | var view_ids = this.child_model_views[child_model.id]; | |
|
330 | if (view_ids !== undefined) { | |
|
331 | ||
|
332 | // Only delete the first view in the list. | |
|
333 | var view_id = view_ids[0]; | |
|
334 | var view = this.child_views[view_id]; | |
|
335 | delete this.child_views[view_id]; | |
|
336 | view_ids.splice(0,1); | |
|
337 | delete child_model.views[view_id]; | |
|
338 | ||
|
339 | // Remove the view list specific to this model if it is empty. | |
|
340 | if (view_ids.length === 0) { | |
|
341 | delete this.child_model_views[child_model.id]; | |
|
342 | } | |
|
343 | return view; | |
|
344 | } | |
|
345 | return null; | |
|
312 | return this.model.widget_manager.create_view(child_model, options).catch(utils.reject("Couldn't create child view")); | |
|
346 | 313 | }, |
|
347 | 314 | |
|
348 | 315 | callbacks: function(){ |
General Comments 0
You need to be logged in to leave comments.
Login now