Created
February 7, 2013 19:18
-
-
Save dtenenba/4733384 to your computer and use it in GitHub Desktop.
Element click handling in cytoscape.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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