- Using a custom tooltips per the example (all good), would like to be able to call functions elsewhere in my app whenever a node is clicked on / the tooltip presented - is there an easy way to hook into this.
If you want to interact with external objects (outside NeXt), you may define global functions or functions that are visible inside a NeXt's scope. Another nice way around it is to use AngularJS (it especially comes to the rescue in complex apps). You may define controllers and directives and determine the way to interact between scopes within each '$scope'.
To fire this function you might want to use custom scenes. Here's an example:
nx.define('CustomScene', nx.graphic.Topology.DefaultScene, { 'methods': { clickNode: function(sender, node){ alert('node is clicked'); }, clickLink: function(sender, link){ alert('link is clicked'); } } });
This will override default methods, therefore tooltips won't be shown by click. If you need them, I'll follow up with this for you.
Once the scene is defined, you should register and activate it.
topo.on('topologyGenerated', function(sender, event) { sender.registerScene('ce', 'CustomScene'); sender.activateScene('ce'); });
topo is an initialized nx.graphic.Topology object.
Comments
0 comments
Please sign in to leave a comment.