Wait that all resources are loaded and fragments rendered before initializing the xblock

This commit is contained in:
Alan Boudreault
2014-04-24 15:54:23 -04:00
parent 2825f432e1
commit 4d1d1a75ce

View File

@@ -25,18 +25,23 @@ define(["jquery", "underscore", "js/views/baseview", "xblock/runtime.v1"],
},
handleXBlockFragment: function(fragment, options) {
var wrapper = this.$el,
var self = this,
wrapper = this.$el,
xblockElement,
success = options ? options.success : null,
xblock;
this.renderXBlockFragment(fragment, wrapper);
xblockElement = this.$('.xblock').first();
xblock = XBlock.initializeBlock(xblockElement);
this.xblock = xblock;
this.xblockReady(xblock);
if (success) {
success(xblock);
}
xblock,
fragmentsRendered;
fragmentsRendered = this.renderXBlockFragment(fragment, wrapper);
$.when(fragmentsRendered).done(function() {
xblockElement = self.$('.xblock').first();
xblock = XBlock.initializeBlock(xblockElement);
self.xblock = xblock;
self.xblockReady(xblock);
if (success) {
success(xblock);
}
});
},
/**