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:
KesterTong 2014-07-23 16:56:12 -04:00 committed by Thomas Kluyver
parent 077ba397c1
commit 0aada3ac5d
2 changed files with 23 additions and 1 deletions

View File

@ -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,

View File

@ -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 () {