Cytoscape js - Call a function whenever a node is clicked
问题 I initialized the cytoscape like this: var cy = cytoscape({ container: document.getElementById('cy'), elements: [ { data: { id: 'a' } }, { data: { id: 'b' } }, { data: { id: 'c' } }, { data: { id: 'ab', source: 'a', target: 'b' } }, { data: { id: 'ac', source: 'a', target: 'c' } }] }); Then I added a function which adds a new node whenever the user double clicks on the viewport. var nid = 1; document.getElementById("cy").ondblclick = function(e) { cy.add({ data: { id: nid }, renderedPosition: