Show More
@@ -95,10 +95,9 b'' | |||||
95 | var view = new ViewType({model: model, widget_manager: this, cell: cell}); |
|
95 | var view = new ViewType({model: model, widget_manager: this, cell: cell}); | |
96 | view.render(); |
|
96 | view.render(); | |
97 | model.views.push(view); |
|
97 | model.views.push(view); | |
|
98 | model.on('destroy', view.remove, view); | |||
98 | /* |
|
99 | /* | |
99 | // jng: Handle when the view element is remove from the page. |
|
100 | // TODO: handle view deletion. Don't forget to delete child views | |
100 | // observe the view destruction event and do this. We may need |
|
|||
101 | // to override the view's remove method to trigger this event. |
|
|||
102 | var that = this; |
|
101 | var that = this; | |
103 | view.$el.on("remove", function () { |
|
102 | view.$el.on("remove", function () { | |
104 | var index = that.views.indexOf(view); |
|
103 | var index = that.views.indexOf(view); | |
@@ -109,7 +108,7 b'' | |||||
109 |
|
108 | |||
110 | // Close the comm if there are no views left. |
|
109 | // Close the comm if there are no views left. | |
111 | if (that.views.length() === 0) { |
|
110 | if (that.views.length() === 0) { | |
112 |
// |
|
111 | //trigger comm close event? | |
113 | } |
|
112 | } | |
114 |
|
113 | |||
115 |
|
114 |
@@ -41,7 +41,6 b' function(widget_manager, underscore, backbone){' | |||||
41 | comm.on_close($.proxy(this._handle_comm_closed, this)); |
|
41 | comm.on_close($.proxy(this._handle_comm_closed, this)); | |
42 | comm.on_msg($.proxy(this._handle_comm_msg, this)); |
|
42 | comm.on_msg($.proxy(this._handle_comm_msg, this)); | |
43 | } |
|
43 | } | |
44 |
|
||||
45 | return Backbone.Model.apply(this); |
|
44 | return Backbone.Model.apply(this); | |
46 | }, |
|
45 | }, | |
47 |
|
46 | |||
@@ -54,12 +53,11 b' function(widget_manager, underscore, backbone){' | |||||
54 |
|
53 | |||
55 | // Handle when a widget is closed. |
|
54 | // Handle when a widget is closed. | |
56 | _handle_comm_closed: function (msg) { |
|
55 | _handle_comm_closed: function (msg) { | |
57 | // jng: widget manager should observe the comm_close event and delete views when triggered |
|
|||
58 |
|
||||
59 | this.trigger('comm:close'); |
|
56 | this.trigger('comm:close'); | |
60 | delete this.comm.model; // Delete ref so GC will collect widget model. |
|
57 | delete this.comm.model; // Delete ref so GC will collect widget model. | |
61 | delete this.comm; |
|
58 | delete this.comm; | |
62 | delete this.widget_id; // Delete id from model so widget manager cleans up. |
|
59 | delete this.widget_id; // Delete id from model so widget manager cleans up. | |
|
60 | // TODO: Handle deletion, like this.destroy(), and delete views, etc. | |||
63 | }, |
|
61 | }, | |
64 |
|
62 | |||
65 |
|
63 |
General Comments 0
You need to be logged in to leave comments.
Login now