Move the display Promise into a lower level method,

into the create view method of the widget manager.
This makes sure that views created by parent views
are also accounted for in the state/display order
guarantee.
Jonathan Frederic 12 years ago
parent 6ee932f298
commit b3c49fce66

@ -93,7 +93,12 @@ define([
WidgetManager.prototype.create_view = function(model, options) {
// Creates a promise for a view of a given model
return utils.load_class(model.get('_view_name'), model.get('_view_module'),
// Make sure the view creation is not out of order with
// any state updates.
model.state_change = model.state_change.then(function() {
console.log('create_view ' + model.id);
return utils.load_class(model.get('_view_name'), model.get('_view_module'),
WidgetManager._view_types).then(function(ViewType) {
// If a view is passed into the method, use that view's cell as
@ -109,6 +114,8 @@ define([
view.render();
return view;
}, utils.reject("Couldn't create a view for model id '" + String(model.id) + "'"));
});
return model.state_change;
};
WidgetManager.prototype.get_msg_cell = function (msg_id) {

@ -81,9 +81,8 @@ define(["widgets/js/manager",
this.trigger('msg:custom', msg.content.data.content);
break;
case 'display':
this.state_change = this.state_change.then(function () {
return that.widget_manager.display_view(msg, that);
}).catch(utils.reject("Couldn't process display msg for model id '" + String(that.id) + "'", true));
that.widget_manager.display_view(msg, that)
.catch(utils.reject("Couldn't process display msg for model id '" + String(that.id) + "'", true));
break;
}
},
@ -94,6 +93,8 @@ define(["widgets/js/manager",
return this._unpack_models(state).then(function(state) {
that.state_lock = state;
try {
console.log('set_state ' + that.id);
console.log(state);
WidgetModel.__super__.set.call(that, state);
} finally {
that.state_lock = null;

Loading…
Cancel
Save