mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-06 11:35:24 +08:00
autosave & reload on kernelspec switch
when a custom kernel.js was defined, in which case reload is needed to ensure clean js state.
This commit is contained in:
parent
ad3dd60b3f
commit
8c3b6d79d0
@ -94,6 +94,7 @@ define([
|
|||||||
|
|
||||||
KernelSelector.prototype._spec_changed = function (event, ks) {
|
KernelSelector.prototype._spec_changed = function (event, ks) {
|
||||||
/** event handler for spec_changed */
|
/** event handler for spec_changed */
|
||||||
|
var that = this;
|
||||||
|
|
||||||
// update selection
|
// update selection
|
||||||
this.current_selection = ks.name;
|
this.current_selection = ks.name;
|
||||||
@ -157,6 +158,15 @@ define([
|
|||||||
console.warn("Failed to load kernel.js from ", ks.resources['kernel.js'], err);
|
console.warn("Failed to load kernel.js from ", ks.resources['kernel.js'], err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
this.events.on('spec_changed.Kernel', function (evt, new_ks) {
|
||||||
|
if (ks.name != new_ks.name) {
|
||||||
|
console.warn("kernelspec %s had custom kernel.js. Forcing page reload for %s.",
|
||||||
|
ks.name, new_ks.name);
|
||||||
|
that.notebook.save_notebook().then(function () {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user