From 8c3b6d79d0ac7dd6d849630d137abda3a8cfed53 Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 30 Mar 2015 14:29:56 -0700 Subject: [PATCH] autosave & reload on kernelspec switch when a custom kernel.js was defined, in which case reload is needed to ensure clean js state. --- IPython/html/static/notebook/js/kernelselector.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/IPython/html/static/notebook/js/kernelselector.js b/IPython/html/static/notebook/js/kernelselector.js index d9711aaef..8e9936250 100644 --- a/IPython/html/static/notebook/js/kernelselector.js +++ b/IPython/html/static/notebook/js/kernelselector.js @@ -94,6 +94,7 @@ define([ KernelSelector.prototype._spec_changed = function (event, ks) { /** event handler for spec_changed */ + var that = this; // update selection this.current_selection = ks.name; @@ -157,6 +158,15 @@ define([ 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(); + }); + } + }); } };