Skip to content

Instantly share code, notes, and snippets.

@dtenenba
Created February 7, 2013 19:18
Show Gist options
  • Save dtenenba/4733384 to your computer and use it in GitHub Desktop.
Save dtenenba/4733384 to your computer and use it in GitHub Desktop.
Element click handling in cytoscape.js
cy.on('click', function(event){
// cyTarget holds a reference to the originator
// of the event (core or element)
var evtTarget = event.cyTarget;
window.evtTarget = evtTarget;
if( evtTarget === cy ){
console.log('click on background');
} else {
console.log('click on some element');
console.log("clicked on " + evtTarget.data("id"));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment