##// END OF EJS Templates
Merge pull request #6168 from SylvainCorlay/once-displayed...
Brian E. Granger -
r17332:49e0eabd merge
parent child Browse files
Show More
@@ -277,6 +277,9 b' define(["widgets/js/manager",'
277 this.child_views = {};
277 this.child_views = {};
278 this.model.views.push(this);
278 this.model.views.push(this);
279 this.id = this.id || IPython.utils.uuid();
279 this.id = this.id || IPython.utils.uuid();
280 this.on('displayed', function() {
281 this.is_displayed = true;
282 }, this);
280 },
283 },
281
284
282 update: function(){
285 update: function(){
@@ -388,6 +391,16 b' define(["widgets/js/manager",'
388 touch: function () {
391 touch: function () {
389 this.model.save_changes(this.callbacks());
392 this.model.save_changes(this.callbacks());
390 },
393 },
394
395 after_displayed: function (callback, context) {
396 // Calls the callback right away is the view is already displayed
397 // otherwise, register the callback to the 'displayed' event.
398 if (this.is_displayed) {
399 callback.apply(context);
400 } else {
401 this.on('displayed', callback, context);
402 }
403 },
391 });
404 });
392
405
393
406
@@ -17,18 +17,6 b' define(['
17 this.update_children(model.previous('children'), value);
17 this.update_children(model.previous('children'), value);
18 }, this);
18 }, this);
19 this.update();
19 this.update();
20
21 // Trigger model displayed events for any models that are child to
22 // this model when this model is displayed.
23 var that = this;
24 this.on('displayed', function(){
25 that.is_displayed = true;
26 for (var property in that.child_views) {
27 if (that.child_views.hasOwnProperty(property)) {
28 that.child_views[property].trigger('displayed');
29 }
30 }
31 });
32 },
20 },
33
21
34 update_children: function(old_list, new_list) {
22 update_children: function(old_list, new_list) {
@@ -49,10 +37,10 b' define(['
49 var view = this.create_child_view(model);
37 var view = this.create_child_view(model);
50 this.$el.append(view.$el);
38 this.$el.append(view.$el);
51
39
52 // Trigger the displayed event if this model is displayed.
40 // Trigger the displayed event once this view is displayed.
53 if (this.is_displayed) {
41 this.after_displayed(function() {
54 view.trigger('displayed');
42 view.trigger('displayed');
55 }
43 });
56 },
44 },
57
45
58 update: function(){
46 update: function(){
@@ -179,17 +167,6 b' define(['
179 this.update_children(model.previous('children'), value);
167 this.update_children(model.previous('children'), value);
180 }, this);
168 }, this);
181 this.update();
169 this.update();
182
183 // Trigger model displayed events for any models that are child to
184 // this model when this model is displayed.
185 this.on('displayed', function(){
186 that.is_displayed = true;
187 for (var property in that.child_views) {
188 if (that.child_views.hasOwnProperty(property)) {
189 that.child_views[property].trigger('displayed');
190 }
191 }
192 });
193 },
170 },
194
171
195 hide: function() {
172 hide: function() {
@@ -252,10 +229,10 b' define(['
252 var view = this.create_child_view(model);
229 var view = this.create_child_view(model);
253 this.$body.append(view.$el);
230 this.$body.append(view.$el);
254
231
255 // Trigger the displayed event if this model is displayed.
232 // Trigger the displayed event once this view is displayed.
256 if (this.is_displayed) {
233 this.after_displayed(function() {
257 view.trigger('displayed');
234 view.trigger('displayed');
258 }
235 });
259 },
236 },
260
237
261 update: function(){
238 update: function(){
General Comments 0
You need to be logged in to leave comments. Login now