cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
891
Views
2
Helpful
3
Replies

hook into (custom) tooltip display?

jawalke2
Cisco Employee
Cisco Employee

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

3 Replies 3

alzverev
Cisco Employee
Cisco Employee

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

alzverev
Cisco Employee
Cisco Employee

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

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!).