Reputation: 12207
I want users to hide nodes in a cytoscape.js graph but also have a reset function. How should I initialize hiddenNodes
in the following code? I looked at http://js.cytoscape.org/#collection/building--filtering which tells me how to add and remove nodes from a collection but not how to create an empty one.
var hiddenNodes = ?
function hide(nodes)
{
nodes.hide();
hiddenNodes = hiddenNodes.union(nodes);
}
function reset()
{
hiddenNodes.show();
}
P.S.: The hidden nodes are just a MWE, I know I could do this with selectors also.
P.P.S.: Are there alternative functions for union and difference that change the collection directly or are there only those who return new objects?
Upvotes: 1
Views: 977
Reputation: 338
From the documentation for collection: cy.collection() - Get an empty collection
Upvotes: 2