简体   繁体   中英

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM