##// END OF EJS Templates
Fixed bugs in displayed event triggering for containers
Jonathan Frederic -
Show More
@@ -123,6 +123,7
123 123 model.on('destroy', view.remove, view);
124 124 return view;
125 125 }
126 console.log('VIEW NOT REGISTERED?!');
126 127 return null;
127 128 };
128 129
@@ -27,6 +27,18 define(["widgets/js/widget"], function(WidgetManager) {
27 27 this.update_children(model.previous('_children'), value);
28 28 }, this);
29 29 this.update();
30
31 // Trigger model displayed events for any models that are child to
32 // this model when this model is displayed.
33 var that = this;
34 this.model.on('displayed', function(){
35 that.is_displayed = true;
36 for (var property in that.child_views) {
37 if (that.child_views.hasOwnProperty(property)) {
38 that.child_views[property].model.trigger('displayed');
39 }
40 }
41 });
30 42 },
31 43
32 44 update_children: function(old_list, new_list) {
@@ -47,6 +59,11 define(["widgets/js/widget"], function(WidgetManager) {
47 59 // Called when a model is added to the children list.
48 60 var view = this.create_child_view(model);
49 61 this.$el.append(view.$el);
62
63 // Trigger the displayed event if this model is displayed.
64 if (this.is_displayed) {
65 model.trigger('displayed');
66 }
50 67 },
51 68
52 69 update: function(){
@@ -81,7 +98,7 define(["widgets/js/widget"], function(WidgetManager) {
81 98 // need to know about all of the top-level widgets. The IPython
82 99 // widget manager uses this to register the elements with the
83 100 // keyboard manager.
84 this.additional_elements = [this.$window]
101 this.additional_elements = [this.$window];
85 102
86 103 this.$title_bar = $('<div />')
87 104 .addClass('popover-title')
@@ -169,6 +186,17 define(["widgets/js/widget"], function(WidgetManager) {
169 186 this.update_children(model.previous('_children'), value);
170 187 }, this);
171 188 this.update();
189
190 // Trigger model displayed events for any models that are child to
191 // this model when this model is displayed.
192 this.model.on('displayed', function(){
193 that.is_displayed = true;
194 for (var property in that.child_views) {
195 if (that.child_views.hasOwnProperty(property)) {
196 that.child_views[property].model.trigger('displayed');
197 }
198 }
199 });
172 200 },
173 201
174 202 hide: function() {
@@ -228,6 +256,11 define(["widgets/js/widget"], function(WidgetManager) {
228 256 // Called when a child is added to children list.
229 257 var view = this.create_child_view(model);
230 258 this.$body.append(view.$el);
259
260 // Trigger the displayed event if this model is displayed.
261 if (this.is_displayed) {
262 model.trigger('displayed');
263 }
231 264 },
232 265
233 266 update: function(){
@@ -35,8 +35,17 define(["widgets/js/widget"], function(WidgetManager){
35 35 this.model.on('change:_titles', function(model, value, options) {
36 36 this.update_titles(value);
37 37 }, this);
38 var that = this;
38 39 this.model.on('displayed', function() {
39 40 this.update_titles();
41 // Trigger model displayed events for any models that are child to
42 // this model when this model is displayed.
43 that.is_displayed = true;
44 for (var property in that.child_views) {
45 if (that.child_views.hasOwnProperty(property)) {
46 that.child_views[property].model.trigger('displayed');
47 }
48 }
40 49 }, this);
41 50 },
42 51
@@ -125,6 +134,11 define(["widgets/js/widget"], function(WidgetManager){
125 134
126 135 this.update();
127 136 this.update_titles();
137
138 // Trigger the displayed event if this model is displayed.
139 if (this.is_displayed) {
140 model.trigger('displayed');
141 }
128 142 },
129 143 });
130 144 WidgetManager.register_widget_view('AccordionView', AccordionView);
@@ -153,6 +167,17 define(["widgets/js/widget"], function(WidgetManager){
153 167 this.model.on('change:_children', function(model, value, options) {
154 168 this.update_children(model.previous('_children'), value);
155 169 }, this);
170
171 // Trigger model displayed events for any models that are child to
172 // this model when this model is displayed.
173 this.model.on('displayed', function(){
174 that.is_displayed = true;
175 for (var property in that.child_views) {
176 if (that.child_views.hasOwnProperty(property)) {
177 that.child_views[property].model.trigger('displayed');
178 }
179 }
180 });
156 181 },
157 182
158 183 update_children: function(old_list, new_list) {
@@ -206,6 +231,11 define(["widgets/js/widget"], function(WidgetManager){
206 231 .append(view.$el)
207 232 .appendTo(this.$tab_contents);
208 233 view.parent_container = contents_div;
234
235 // Trigger the displayed event if this model is displayed.
236 if (this.is_displayed) {
237 model.trigger('displayed');
238 }
209 239 },
210 240
211 241 update: function(options) {
General Comments 0
You need to be logged in to leave comments. Login now