pbardou
pbardou

Reputation: 3

cytoscape.js accessing object

I build a cytoscape object in a div and set all parameters required what is working just fine! On the "tap" event I add a class to the node just like this:

ready: function(){
   window.cy = this;
   cy.elements().unselectify();
   cy.on('tap', 'node', function(e){
   var node = e.cyTarget; 
   node.addClass('test');

What I want is to select nodes with this class but from outside the ready code, when clicking on a button of the web page. There is any way to do so ?

thanks for your reply!

Upvotes: 0

Views: 725

Answers (1)

maxkfranz
maxkfranz

Reputation: 12250

If you have access to your cy object, you can use cy.$() with any of the available selectors. The ready event is to know when your graph has loaded and finished the initial layout.

Upvotes: 2

Related Questions