##// END OF EJS Templates
Fix view rendering order.
Jonathan Frederic -
Show More
@@ -66,7 +66,7 b' define(['
66 66 dummy.replaceWith(view.$el);
67 67 }
68 68 view.trigger('displayed');
69 }, function(error) { console.error(error); });
69 }, console.error);
70 70 }
71 71 };
72 72
@@ -200,7 +200,7 b' define(['
200 200 // model_name: 'WidgetModel',
201 201 // widget_class: 'IPython.html.widgets.widget_int.IntSlider'})
202 202 // .then(function(model) { console.log('Create success!', model); },
203 // function(error) { console.error(error); });
203 // console.error);
204 204 //
205 205 // Parameters
206 206 // ----------
@@ -322,12 +322,11 b' define(["widgets/js/manager",'
322 322 //
323 323 // -given a model and (optionally) a view name if the view name is
324 324 // not given, it defaults to the model's default view attribute.
325
325 return new Promise(function(resolve, reject) {
326 326 // TODO: this is hacky, and makes the view depend on this cell attribute and widget manager behavior
327 327 // it would be great to have the widget manager add the cell metadata
328 328 // to the subview without having to add it here.
329 329 var that = this;
330 var old_callback = options.callback || function(view) {};
331 330 options = $.extend({ parent: this }, options || {});
332 331
333 332 this.model.widget_manager.create_view(child_model, options).then(function(child_view) {
@@ -339,8 +338,9 b' define(["widgets/js/manager",'
339 338
340 339 // Remember the view by id.
341 340 that.child_views[child_view.id] = child_view;
342 old_callback(child_view);
343 }, function(error) { console.error(error); });
341 resolve(child_view);
342 }, reject);
343 });
344 344 },
345 345
346 346 pop_child_view: function(child_model) {
@@ -75,14 +75,16 b' define(['
75 75 add_child_model: function(model) {
76 76 // Called when a model is added to the children list.
77 77 var that = this;
78 this.create_child_view(model, {callback: function(view) {
79 that.$box.append(view.$el);
78 var dummy = $('<div/>');
79 that.$box.append(dummy);
80 this.create_child_view(model).then(function(view) {
81 dummy.replaceWith(view.$el);
80 82
81 83 // Trigger the displayed event of the child view.
82 84 that.after_displayed(function() {
83 85 view.trigger('displayed');
84 86 });
85 }});
87 }, console.error);
86 88 },
87 89 });
88 90
@@ -114,9 +114,10 b' define(['
114 114 accordion_group.container_index = container_index;
115 115 this.model_containers[model.id] = accordion_group;
116 116
117 this.create_child_view(model, {callback: function(view) {
118 accordion_inner.append(view.$el);
119
117 var dummy = $('<div/>');
118 accordion_inner.append(dummy);
119 this.create_child_view(model).then(function(view) {
120 dummy.replaceWith(view.$el);
120 121 that.update();
121 122 that.update_titles();
122 123
@@ -124,7 +125,7 b' define(['
124 125 that.after_displayed(function() {
125 126 view.trigger('displayed');
126 127 });
127 }});
128 }, console.error);
128 129 },
129 130 });
130 131
@@ -186,8 +187,6 b' define(['
186 187 .css('list-style-type', 'none')
187 188 .appendTo(this.$tabs);
188 189
189 this.create_child_view(model, {callback: function(view) {
190 view.parent_tab = tab;
191 190
192 191 var tab_text = $('<a />')
193 192 .attr('href', '#' + uuid)
@@ -204,18 +203,23 b' define(['
204 203 });
205 204 tab.tab_text_index = that.containers.push(tab_text) - 1;
206 205
206 var dummy = $('<div />');
207 207 var contents_div = $('<div />', {id: uuid})
208 208 .addClass('tab-pane')
209 209 .addClass('fade')
210 .append(view.$el)
210 .append(dummy)
211 211 .appendTo(that.$tab_contents);
212
213 this.create_child_view(model).then(function(view) {
214 dummy.replaceWith(view.$el);
215 view.parent_tab = tab;
212 216 view.parent_container = contents_div;
213 217
214 218 // Trigger the displayed event of the child view.
215 219 that.after_displayed(function() {
216 220 view.trigger('displayed');
217 221 });
218 }});
222 }, console.error);
219 223 },
220 224
221 225 update: function(options) {
General Comments 0
You need to be logged in to leave comments. Login now