1

Hi can someone please tell me how I am supposed to setup and use the jquery.cxtmenu that comes packaged with cytoscape.js? I can't seem to find any documentation on it.

I've included the script file but I am not sure how to initialise and setup my menu.

Update: I think there is a bug in the code? I'm not sure but it seems to be calling a function that doesn't exist on right mouse click.

 ele.renderedPosition()

Many thanks.

user1768233
  • 1,409
  • 3
  • 20
  • 28

1 Answers1

2

The plugins will be better documented with the next release when the documentation is improved and when the plugins are separated on the jQuery plugin system (they are jQuery plugins after all).

For now, here is an example for you:

$('#graph').cxtmenu({
  selector: 'node',
  commands: [
    {
      content: '<span class="icon-arrow-right"></span><label>Connect</label>',
      select: function(){
        $('#graph').cytoscapeEdgehandles('start', this.id());
      }
    },

    {
      content: '<span class="icon-remove destructive-light"></span><label class="">Delete</label>',
      select: function(){
        doc.removeEntity( this.id() );
      }
    }

  ]
});
maxkfranz
  • 11,896
  • 1
  • 27
  • 36
  • Thanks Max, and thank you very much for this fantastic library. I don't mean to be a pain, but do you have an example of how to use the cytoscapeEdgehandles library as well? If not that is totally fine. Many thanks again – user1768233 Oct 12 '13 at 04:47
  • https://github.com/PathwayCommons/factoid/blob/master/lib/app/client/cytoscape.js#L183 – maxkfranz Oct 15 '13 at 18:07
  • fyi if you want to use the above code example with the examples copy/pasted from the cytoscape.js docs, you'll need to change #graph to #cy – andy Jan 12 '14 at 22:20
  • also: i'm getting "doc.removeEntity is not a function" - what does doc refer to? – andy Jan 12 '14 at 22:26
  • It's app-specific code that you should replace with your own. -M – maxkfranz Jan 13 '14 at 00:36