Skip to content

Commit 51acfb6

Browse files
committed
Use event.preventDefault() on links creating new files & folders
1 parent 1d84d83 commit 51acfb6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

notebook/static/tree/js/newnotebook.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ define([
7373
this.events.trigger('kernelspecs_loaded.KernelSpec', data.kernelspecs);
7474
};
7575

76-
NewNotebookWidget.prototype.new_notebook = function (kernel_name) {
76+
NewNotebookWidget.prototype.new_notebook = function (kernel_name, evt) {
7777
/** create and open a new notebook */
7878
var that = this;
7979
kernel_name = kernel_name || this.default_kernel;
@@ -107,6 +107,9 @@ define([
107107
}
108108
});
109109
});
110+
if (evt !== undefined) {
111+
evt.preventDefault();
112+
}
110113
};
111114

112115
return {'NewNotebookWidget': NewNotebookWidget};

notebook/static/tree/js/notebooklist.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ define([
169169
console.warn('Error during New file creation', e);
170170
});
171171
that.load_sessions();
172+
e.preventDefault();
172173
});
173174
$('#new-folder').click(function(e) {
174175
that.contents.new_untitled(that.notebook_path || '', {type: 'directory'})
@@ -189,6 +190,7 @@ define([
189190
console.warn('Error during New directory creation', e);
190191
});
191192
that.load_sessions();
193+
e.preventDefault();
192194
});
193195

194196
// Bind events for action buttons.
@@ -373,8 +375,8 @@ define([
373375
breadcrumb.append(root);
374376
var path_parts = [];
375377
this.notebook_path.split('/').forEach(function(path_part) {
376-
path_parts.push(path_part)
377-
var path = path_parts.join('/')
378+
path_parts.push(path_part);
379+
var path = path_parts.join('/');
378380
var url = utils.url_path_join(
379381
that.base_url,
380382
'/tree',

0 commit comments

Comments
 (0)