0

I'd like to trigger an event (change the data of source and target nodes) when edge creation is complete using js.cytoscape edgehandles. I need this to happen only when the edge has definitely been created (see Note below).

How can I achieve this? May I customize the complete function at the beginning of the js.cytoscape-edgehandles file?

complete: function( sourceNode, targetNodes, addedEntities ){

  // fired when edgehandles is done and entities are added
},

So far I have customized the makeEdges function. But the result is that events may be triggered before the edge creation process is completed.

function makeEdges( preview, src, tgt ){}

Would you recommend to rewrite the code and customize the edgeParams() and complete() functions?

Thanks,

Umbolt

(Note) In my code, the width of created edges is a function of the source node data, which is altered once an edge has been created. If data alteration happens before completion, source and target node data may be altered although the edge has not been created, which affects subsequent edge creation.

umbolt
  • 23
  • 6
  • Please, provide [jsFiddle](http://stackoverflow.com/help/mcve) which reproduces your problem so that we can play with it (more than just a thought experiment). BTW: modifying the core library would be typically the last thing to consider and you can always handle the "even after" requirement by posting a message into the future with [window.setTimeout](https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Timers) or something similar – xmojmr Apr 03 '15 at 06:25

1 Answers1

0

I think it is necessary for complete() to be called on cancellation in addition to completion for certain usecases. For your usecase, I believe you could simply check whether there are any addedEntities. If so, then you could call your own callback with your logic.

maxkfranz
  • 11,896
  • 1
  • 27
  • 36