diff --git a/IPython/html/static/notebook/js/kernelselector.js b/IPython/html/static/notebook/js/kernelselector.js
index 1d5e9fa97..9be8936f2 100644
--- a/IPython/html/static/notebook/js/kernelselector.js
+++ b/IPython/html/static/notebook/js/kernelselector.js
@@ -9,6 +9,7 @@ define([
"use strict";
var KernelSelector = function(selector, notebook) {
+ var that = this;
this.selector = selector;
this.notebook = notebook;
this.notebook.set_kernelselector(this);
@@ -22,6 +23,11 @@ define([
this.bind_events();
// Make the object globally available for user convenience & inspection
IPython.kernelselector = this;
+ this._finish_load = null;
+ this.loaded = new Promise(function(resolve, reject) {
+ that._finish_load = resolve;
+ });
+
Object.seal(this);
};
@@ -67,6 +73,8 @@ define([
.text(ks.spec.display_name));
new_notebook_submenu.append(ks_submenu_entry);
}
+ // trigger loaded promise
+ this._finish_load();
};
KernelSelector.prototype._spec_changed = function (event, ks) {
diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js
index e6ca53371..0cbb8c81f 100644
--- a/IPython/html/static/notebook/js/notebook.js
+++ b/IPython/html/static/notebook/js/notebook.js
@@ -2077,11 +2077,16 @@ define([
* @param {string} notebook_path - A notebook to load
*/
Notebook.prototype.load_notebook = function (notebook_path) {
+ var that = this;
this.notebook_path = notebook_path;
this.notebook_name = utils.url_path_split(this.notebook_path)[1];
this.events.trigger('notebook_loading.Notebook');
this.contents.get(notebook_path, {type: 'notebook'}).then(
- $.proxy(this.load_notebook_success, this),
+ function (data) {
+ that.kernel_selector.loaded.then(
+ that.load_notebook_success(data)
+ );
+ },
$.proxy(this.load_notebook_error, this)
);
};