Jim Jonah
Jim Jonah

Reputation: 21

Attach a context menu (context.js) to a node in cytoscape.js

Since the nodes in a cytoscape.js graph are on a canvas I'm not sure how to go about marrying the two together.

I guess a generic version of the question is, how can jQuery find a node?

I've tried the cytoscape.js-cxtmenu circular context menu. And while it's very cool, we'd like a more traditional popup menu. In another SO question (which is closed) context.js was recommended.

Reusing the demo.js from that page it seems line I need to modify this line

context.attach($("#layer2-node").get(0))

and replace it with something like

context.attach(document.getElementById('cy').elements())

however, that doesn't seem to work.

thoughts?

Upvotes: 1

Views: 819

Answers (1)

maxkfranz
maxkfranz

Reputation: 12242

Generally, you have to create dummy DOM elements per node as needed to call a DOM library. This is the approach the qtip extension uses, creating divs on demand.

If you can specify positions/offsets in the lib, then you could alternatively just use your container DOM element.

Upvotes: 1

Related Questions