I want to display several instances of cytoscape in a single page, in a time sequence: first one set of nodes are displayed on the graph, the user must create edges between them, then he moves to a second graph, etc.
There seems to be a conflict between my reinitialisation code and cy.edgehandles. In the first instance, everything works fine. From the second instance on, the "ghost" edges are not displayed while draging the edges.
I get the following error message in the console:
jquery.cytoscape.js-edgehandles.js:333 Uncaught TypeError: Cannot read property 'id' of null jquery.cytoscape.js-edgehandles.js:333 $.fn.cytoscapeEdgehandles.functions.init.drawLine jquery.cytoscape.js-edgehandles.js:732 moveHandler jquery-2.0.3.min.js:5 x.event.dispatchjquery-2.0.3.min.js:5 x.event.add.y.handle
The variable that appears to be "null" is :
333: source: sourceNode.id(),
Here is the code I wrote to reinitialise the cy.instance:
$('#next').click(function(){
indexLevel++;// index to move from one instance to the next.
cy.load(elesJson);// load nodes collection
cy.ready();
});
Here is my code:
//elements
$(function(){
var elesJson = {
nodes: [{ data: { id: 'S'} }...],
edges: [{ data: { id: 'loan', source: 'B', target: 'U' } },...]};
// instance index
var indexLevel=0;
// cy initialisation
$("#cy"+indexLevel).cytoscape({
style: cytoscape.stylesheet()...
elements: elesJson,
ready: function(){window.cy = this;cy.zoomingEnabled( false );
cy.panningEnabled( false );});
Any solution to this?