1
0
Fork 0

Deleting nodes now works and redraws the graph, in the demo page deleting has been included

This commit is contained in:
Michael Hackstein 2013-03-21 15:57:36 +01:00
parent a4065dd30d
commit 60416e671a
3 changed files with 11 additions and 6 deletions

View File

@ -255,7 +255,7 @@
}
function bindDelete() {
viewer.rebind({})
viewer.rebind({deleteNode: {target: "nodes", type: "click", callback: function() {console.log("Gone AWAY!");}}})
}
var viewer;

View File

@ -203,7 +203,10 @@ function EventLibrary() {
nodeShaper = config.shaper;
return function(nodeToDelete, callback) {
adapter.deleteNode(nodeToDelete, callback);
adapter.deleteNode(nodeToDelete, function() {
nodeShaper.drawNodes(nodes);
callback();
});
};
};

View File

@ -68,8 +68,6 @@ function GraphViewer(svg, width, height,
throw "Events config has to be given";
}
var self = this,
adapter,
nodeShaper,
@ -122,10 +120,14 @@ function GraphViewer(svg, width, height,
dispatcher.events.PATCHNODE);
}
if (checkDefs(conf.deleteNode)) {
if (checkDefs(conf.deleteNode)
&& checkFunction(conf.deleteNode.callback)) {
dispatcher.bind(conf.deleteNode.target,
conf.deleteNode.type,
dispatcher.events.DELETENODE);
function(n) {
dispatcher.events.DELETENODE(n, conf.deleteNode.callback);
}
);
}
if (conf.custom !== undefined) {
_.each(conf.custom, function(toBind) {