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() { function bindDelete() {
viewer.rebind({}) viewer.rebind({deleteNode: {target: "nodes", type: "click", callback: function() {console.log("Gone AWAY!");}}})
} }
var viewer; var viewer;

View File

@ -203,7 +203,10 @@ function EventLibrary() {
nodeShaper = config.shaper; nodeShaper = config.shaper;
return function(nodeToDelete, callback) { 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"; throw "Events config has to be given";
} }
var self = this, var self = this,
adapter, adapter,
nodeShaper, nodeShaper,
@ -122,10 +120,14 @@ function GraphViewer(svg, width, height,
dispatcher.events.PATCHNODE); dispatcher.events.PATCHNODE);
} }
if (checkDefs(conf.deleteNode)) { if (checkDefs(conf.deleteNode)
&& checkFunction(conf.deleteNode.callback)) {
dispatcher.bind(conf.deleteNode.target, dispatcher.bind(conf.deleteNode.target,
conf.deleteNode.type, conf.deleteNode.type,
dispatcher.events.DELETENODE); function(n) {
dispatcher.events.DELETENODE(n, conf.deleteNode.callback);
}
);
} }
if (conf.custom !== undefined) { if (conf.custom !== undefined) {
_.each(conf.custom, function(toBind) { _.each(conf.custom, function(toBind) {