Create a customized Node class with clickNode event handler

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2016 09:00 AM
Hi all,
I would like to create a node. If I click or select the node, there will be a message in the console.
Here are my codes.
nx.define('MyExtendNode', nx.graphic.Topology.Node, {
view: function(view) {
view.content[2].events.clickNode = this._nodeClick;
return view;
},
methods: {
init: function(options) {
this.inherited(options);
},
dispose: function() {
this.inherited();
},
_nodeClick: function(sender, event){
console.log('node clicked')
}
}
});
But there is no message in console.
How could I create a customized Node class?
- Labels:
-
NeXt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2016 01:16 PM
Hi Tzuche,
About your customized node class, you should do two small modification.
1. view.content[2].events.clickNode should be view.content[2].events.click
2. Because NeXt view engine will parse the view json. So you should follow the syntax of view definition. like:
view.content[2].events.click = "{#_nodeClick}"
I am thinking we should add your syntax support too. Will update that sooner.
I made an example for your reference.
http://codepen.io/NEXTSUPPORT/pen/YqONOj?editors=0010
For create customized node class, you can refer these example. Extend - > Extend Node
https://developer.cisco.com/site/neXt/discover/demo/
Thanks,
Abu
