fix event hookup for kernel changed

event is kernel_created.Session

The spec name on the kernel also wasn't being changed when the kernel changed.
This commit is contained in:
Min RK 2014-11-15 12:19:35 -08:00
parent 17826aa0f9
commit c1a664dfb9
2 changed files with 6 additions and 4 deletions

View File

@ -76,12 +76,12 @@ define([
that.element.find("#current_kernel_spec").find('.kernel_name').text(data.display_name);
});
this.events.on('started.Session', function(events, session) {
if (session.kernel_name !== that.current_selection) {
this.events.on('kernel_created.Session', function(event, data) {
if (data.kernel.name !== that.current_selection) {
// If we created a 'python' session, we only know if it's Python
// 3 or 2 on the server's reply, so we fire the event again to
// set things up.
var ks = that.kernelspecs[session.kernel_name];
var ks = that.kernelspecs[data.kernel.name];
that.events.trigger('spec_changed.Kernel', ks);
}
});

View File

@ -97,7 +97,9 @@ define([
Session.prototype.start = function (success, error) {
var that = this;
var on_success = function (data, status, xhr) {
if (!that.kernel) {
if (that.kernel) {
that.kernel.name = that.kernel_model.name;
} else {
var kernel_service_url = utils.url_path_join(that.base_url, "api/kernels");
that.kernel = new kernel.Kernel(kernel_service_url, that.ws_url, that.notebook, that.kernel_model.name);
}