Based on this question and answer , I made it a JSFiddle .
What I'm trying to do is find a way to correctly export / import JSON data in cytoscape.js.
I use JSON.stringify(cy.json())to get JSON data from the elements, and on the other hand, I clear the area cyand use cy.add(text-input)to add the elements back.
Ie: you can add node, copy its JSON data, then you can update your browser and paste JSON data from node directly, try adding it to cy.
But I couldn't get this to work, and I can't figure out where I am going wrong (possibly using a function cy.add). Always getting both errors:
An element must be of type 'nodes' or 'edges'; you specified 'undefined'
Uncaught TypeError: Cannot read property 'single' of undefined
Any ideas?
Thanks in advance.
source
share