From 51acfb61ad3725650b3a2397b1ce7816a1a2f6e9 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Fri, 26 Jan 2018 08:49:43 +0000 Subject: [PATCH] Use event.preventDefault() on links creating new files & folders --- notebook/static/tree/js/newnotebook.js | 5 ++++- notebook/static/tree/js/notebooklist.js | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/notebook/static/tree/js/newnotebook.js b/notebook/static/tree/js/newnotebook.js index 32445c58d..d0ea5d5c2 100644 --- a/notebook/static/tree/js/newnotebook.js +++ b/notebook/static/tree/js/newnotebook.js @@ -73,7 +73,7 @@ define([ this.events.trigger('kernelspecs_loaded.KernelSpec', data.kernelspecs); }; - NewNotebookWidget.prototype.new_notebook = function (kernel_name) { + NewNotebookWidget.prototype.new_notebook = function (kernel_name, evt) { /** create and open a new notebook */ var that = this; kernel_name = kernel_name || this.default_kernel; @@ -107,6 +107,9 @@ define([ } }); }); + if (evt !== undefined) { + evt.preventDefault(); + } }; return {'NewNotebookWidget': NewNotebookWidget}; diff --git a/notebook/static/tree/js/notebooklist.js b/notebook/static/tree/js/notebooklist.js index 1abadbf86..e38925c9f 100644 --- a/notebook/static/tree/js/notebooklist.js +++ b/notebook/static/tree/js/notebooklist.js @@ -169,6 +169,7 @@ define([ console.warn('Error during New file creation', e); }); that.load_sessions(); + e.preventDefault(); }); $('#new-folder').click(function(e) { that.contents.new_untitled(that.notebook_path || '', {type: 'directory'}) @@ -189,6 +190,7 @@ define([ console.warn('Error during New directory creation', e); }); that.load_sessions(); + e.preventDefault(); }); // Bind events for action buttons. @@ -373,8 +375,8 @@ define([ breadcrumb.append(root); var path_parts = []; this.notebook_path.split('/').forEach(function(path_part) { - path_parts.push(path_part) - var path = path_parts.join('/') + path_parts.push(path_part); + var path = path_parts.join('/'); var url = utils.url_path_join( that.base_url, '/tree',