mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
Remove deleted notebook from notebook list
Uses events to notify the NotebookList when the content manager deletes a notebook, and remove the deleted notebook in response to such an event.
This commit is contained in:
parent
077ba397c1
commit
0aada3ac5d
@ -75,12 +75,19 @@ define([
|
||||
};
|
||||
|
||||
ContentManager.prototype.delete_notebook = function(name, path) {
|
||||
var that = this;
|
||||
var settings = {
|
||||
processData : false,
|
||||
cache : false,
|
||||
type : "DELETE",
|
||||
dataType : "json",
|
||||
error : utils.log_ajax_error,
|
||||
success : function (data, status, xhr) {
|
||||
that.events.trigger('notebook_deleted.ContentManager', {
|
||||
name: name,
|
||||
path: path
|
||||
});
|
||||
},
|
||||
error : utils.log_ajax_error
|
||||
};
|
||||
var url = utils.url_join_encode(
|
||||
this.base_url,
|
||||
|
@ -39,6 +39,21 @@ define([
|
||||
this.session_list.events.on('sessions_loaded.Dashboard',
|
||||
function(e, d) { that.sessions_loaded(d); });
|
||||
}
|
||||
|
||||
|
||||
if (this.content_manager && this.content_manager.events) {
|
||||
this.content_manager.events.on('notebook_deleted.ContentManager',
|
||||
function(e, d) {
|
||||
// Remove the deleted notebook.
|
||||
$( ":data(nbname)" ).each(function() {
|
||||
var element = $( this );
|
||||
if (element.data( "nbname" ) == d.name &&
|
||||
element.data( "path" ) == d.path) {
|
||||
element.remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
NotebookList.prototype.style = function () {
|
||||
|
Loading…
Reference in New Issue
Block a user