12-18-2015 09:25 AM
Hi there,
Another quick question: I'm using custom tooltips per the example (all good), I'd 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?
Thanks in advance,
James
12-19-2015 12:03 PM
Hi James,
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.
- Alex
12-22-2015 10:35 AM
Following up your email (you wanted to display tooltips and hook an event at the same time).
I made a mistake saying that you wouldn't be able to see tooltips. Actually you will.
Alex
12-24-2015 03:24 AM
Thanks, this works fine and as you say the tooltips still work (although you loose the circular highlight around the node, but I can live without this!).
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide