Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic how to find linked node (Read 1229 times)
oxzorxxo
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 13
Joined: Nov 26th, 2018
how to find linked node
Nov 26th, 2018 at 9:59am
Print Post  
am trying to get node which are linked together Angry like, get their id using javascript...
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: how to find linked node
Reply #1 - Nov 26th, 2018 at 11:20am
Print Post  
Follow IncomingLinks -> Origin and OutgoingLinks -> Destination properties -

Code
Select All
function onNodeClicked(sender, args)
{
	var node = args.getNode();

	// find in / parent nodes
	var inLinks = node.getIncomingLinks();
	for (var i = 0; i < inLinks.length; i++)
		console.log(inLinks[i].getOrigin().getText());

	// find out / child nodes
	var outLinks = node.getOutgoingLinks();
	for (var i = 0; i < outLinks.length; i++)
		console.log(outLinks[i].getDestination().getText());
} 



or alternatively -

Code
Select All
// all at once
var allLinks = node.getAllLinks();
for (var i = 0; i < allLinks.length; i++)
{
	var link = allLinks[i];

	// print the other end
	if (link.getOrigin() == node)
		console.log(link.getDestination().getText());
	else
		console.log(link.getOrigin().getText());
} 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
oxzorxxo
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 13
Joined: Nov 26th, 2018
Re: how to find linked node
Reply #2 - Nov 27th, 2018 at 9:44am
Print Post  
thank you for your help ...
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint